<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><head><meta content="text/html; charset=utf-8" http-equiv="Content-Type" /><style><!--/*paged media */ div.header {display: none }div.footer {display: none } /*@media print { */@page { size: A4; margin: 10%; @top-center {content: element(header) } @bottom-center {content: element(footer) } }/*element styles*/ .del  {text-decoration:line-through;color:red;} .ins {text-decoration:none;background:#c0ffc0;padding:1px;}
 /* TABLE STYLES */ 
table.TableNormal {display:table;position: relative; margin-left: 0in;}
table.TableGrid {display:table;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;margin-bottom: 0in;line-height: 100%;}

 /* PARAGRAPH STYLES */ 
.DocDefaults {display:block;margin-bottom: 4mm;line-height: 115%;font-size: 11.0pt;}
.Normal {display:block;}
.NormalWeb {display:block;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;font-size: 12.0pt;}
.Command {display:block;position: relative; margin-left: 0.5in;font-size: 10.0pt;}
.FootnoteText {display:block;margin-bottom: 0in;line-height: 100%;font-size: 10.0pt;}
.Title {display:block;border-bottom-style: solid;border-bottom-width: 0.35mm;border-bottom-color: #4F81BD;margin-bottom: 0.21in;line-height: 100%;color: #17365D;font-size: 26.0pt;}
.Grammar {display:block;position: relative; margin-left: 0.75in;text-indent: -0.25in;margin-bottom: 0.08in;line-height: 104%;font-style: italic;}
.TOC2 {display:block;position: relative; margin-left: 4mm;margin-bottom: 0.07in;}
.Heading1 {display:block;page-break-after: avoid;margin-top: 0.33in;margin-bottom: 4mm;font-weight: bold;color: #365F91;font-size: 18.0pt;}
.TOCHeading {display:block;margin-bottom: 0in;font-size: 14.0pt;}
.TOC1 {display:block;margin-bottom: 0.07in;}
.Heading2 {display:block;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;font-weight: bold;font-style: italic;font-size: 14.0pt;}
.Header {display:block;margin-bottom: 0in;line-height: 100%;}
.ListParagraph {display:block;position: relative; margin-left: 0.5in;}
.Footer {display:block;margin-bottom: 0in;line-height: 100%;}
.Normal-TableGrid-BR {display:block;margin-bottom: 0in;line-height: 100%;font-size: 11.0pt;}
.ListParagraph-TableGrid-BR {display:block;position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;font-size: 11.0pt;}

 /* CHARACTER STYLES */ span.DefaultParagraphFont {display:inline;}
span.xmlmarkuptagname {display:inline;}
span.underline {display:inline;}
span.xmlmarkupattributename {display:inline;}
span.apple-style-span {display:inline;}
span.Strong {display:inline;font-weight: bold;}
span.Emphasis {display:inline;font-style: italic;}
span.FootnoteReference {display:inline;vertical-align: super;font-size: smaller;}
span.apple-converted-space {display:inline;}
span.HTMLCode {display:inline;font-size: 10.0pt;}
span.xmlmarkupbracket {display:inline;}
span.xmlmarkupattributevalue {display:inline;}
span.Hyperlink {display:inline;color: #0000FF;text-decoration: underline;}
span.Terminal {display:inline;font-style: italic;font-size: 10.0pt;}
html, body, div, span, h1, h2, h3, h4, h5, h6, p, a, img,  table, caption, tbody, tfoot, thead, tr, th, td { margin: 0; padding: 0; border: 0;}body {line-height: 1;} --></style><script type="text/javascript"><!--function toggleDiv(divid){if(document.getElementById(divid).style.display == 'none'){document.getElementById(divid).style.display = 'block';}else{document.getElementById(divid).style.display = 'none';}}
--></script></head><body>
  
  <!-- userBodyTop goes here -->
  
  
  
  <div class="document">
  
  <p class="Title Normal DocDefaults "><span class="" style="">Docx4j - Getting Started</span></p>
  
  <p class="TOCHeading Heading1 Normal DocDefaults "><span class="" style="">Contents</span></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637325"><span class="Hyperlink DefaultParagraphFont " style="">What is docx4j?</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637325"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637326"><span class="Hyperlink DefaultParagraphFont " style="">What sorts of things can you do with docx4j?</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637326"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637327"><span class="Hyperlink DefaultParagraphFont " style="">Is docx4j for you?</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637327"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637328"><span class="Hyperlink DefaultParagraphFont " style="">docx4j.NET</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637328"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637329"><span class="Hyperlink DefaultParagraphFont " style="">What Word documents does it support?</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637329"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637330"><span class="Hyperlink DefaultParagraphFont " style="">Handling legacy binary .doc files</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637330"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637331"><span class="Hyperlink DefaultParagraphFont " style="">Getting Help: the docx4j forum</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637331"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637332"><span class="Hyperlink DefaultParagraphFont " style="">Using docx4j via Maven</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637332"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637333"><span class="Hyperlink DefaultParagraphFont " style="">Using docx4j binaries</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637333"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637334"><span class="Hyperlink DefaultParagraphFont " style="">docx4j dependencies</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637334"><span>1</span></a></a></p>
  
  <p class="TOC2 Normal DocDefaults "><a href="#_Toc532637335"><span class="Hyperlink DefaultParagraphFont " style="">slf4j</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637335"><span>1</span></a></a></p>
  
  <p class="TOC2 Normal DocDefaults "><a href="#_Toc532637336"><span class="Hyperlink DefaultParagraphFont " style="">other dependencies</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637336"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637337"><span class="Hyperlink DefaultParagraphFont " style="">JDK versions</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637337"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637338"><span class="Hyperlink DefaultParagraphFont " style="">A word about Jaxb</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637338"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637339"><span class="Hyperlink DefaultParagraphFont " style="">Docx4j source code</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637339"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637340"><span class="Hyperlink DefaultParagraphFont " style="">Javadoc</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637340"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637341"><span class="Hyperlink DefaultParagraphFont " style="">Building docx4j from source</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637341"><span>1</span></a></a></p>
  
  <p class="TOC2 Normal DocDefaults "><a href="#_Toc532637342"><span class="Hyperlink DefaultParagraphFont " style="">Command line -via Maven</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637342"><span>1</span></a></a></p>
  
  <p class="TOC2 Normal DocDefaults "><a href="#_Toc532637343"><span class="Hyperlink DefaultParagraphFont " style="">Command line - via Ant</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637343"><span>1</span></a></a></p>
  
  <p class="TOC2 Normal DocDefaults "><a href="#_Toc532637344"><span class="Hyperlink DefaultParagraphFont " style="">Eclipse</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637344"><span>1</span></a></a></p>
  
  <p class="TOC2 Normal DocDefaults "><a href="#_Toc532637345"><span class="Hyperlink DefaultParagraphFont " style="">Using a different IDE?</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637345"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637346"><span class="Hyperlink DefaultParagraphFont " style="">Open an existing docx/pptx/xlsx document</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637346"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637347"><span class="Hyperlink DefaultParagraphFont " style="">OpenXML concepts</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637347"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637348"><span class="Hyperlink DefaultParagraphFont " style="">Specification versions</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637348"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637349"><span class="Hyperlink DefaultParagraphFont " style="">Architecture</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637349"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637350"><span class="Hyperlink DefaultParagraphFont " style="">Jaxb: marshalling and unmarshalling</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637350"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637351"><span class="Hyperlink DefaultParagraphFont " style="">Parts List</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637351"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637352"><span class="Hyperlink DefaultParagraphFont " style="">MainDocumentPart</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637352"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637353"><span class="Hyperlink DefaultParagraphFont " style="">Samples</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637353"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637354"><span class="Hyperlink DefaultParagraphFont " style="">Creating a new docx</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637354"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637355"><span class="Hyperlink DefaultParagraphFont " style="">docx4j.properties</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637355"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637356"><span class="Hyperlink DefaultParagraphFont " style="">Adding a paragraph of text</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637356"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637357"><span class="Hyperlink DefaultParagraphFont " style="">General strategy/approach for creating stuff</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637357"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637358"><span class="Hyperlink DefaultParagraphFont " style="">Formatting Properties</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637358"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637359"><span class="Hyperlink DefaultParagraphFont " style="">Creating and adding a table</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637359"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637360"><span class="Hyperlink DefaultParagraphFont " style="">Selecting your insertion/editing point;  accessing JAXB nodes via XPath</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637360"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637361"><span class="Hyperlink DefaultParagraphFont " style="">Traversing a document</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637361"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637362"><span class="Hyperlink DefaultParagraphFont " style="">Adding a Part</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637362"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637363"><span class="Hyperlink DefaultParagraphFont " style="">Importing XHTML</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637363"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637364"><span class="Hyperlink DefaultParagraphFont " style="">docx to (X)HTML</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637364"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637365"><span class="Hyperlink DefaultParagraphFont " style="">docx to PDF</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637365"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637366"><span class="Hyperlink DefaultParagraphFont " style="">Image Handling - DOCX</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637366"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637367"><span class="Hyperlink DefaultParagraphFont " style="">Manual Image Manipulation</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637367"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637368"><span class="Hyperlink DefaultParagraphFont " style="">Image Handling – PPTX</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637368"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637369"><span class="Hyperlink DefaultParagraphFont " style="">Adding Headers/Footers</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637369"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637370"><span class="Hyperlink DefaultParagraphFont " style="">Protection Settings</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637370"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637371"><span class="Hyperlink DefaultParagraphFont " style="">docx Table of Contents</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637371"><span>1</span></a></a></p>
  
  <p class="TOC2 Normal DocDefaults "><a href="#_Toc532637372"><span class="Hyperlink DefaultParagraphFont " style="">Introduction</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637372"><span>1</span></a></a></p>
  
  <p class="TOC2 Normal DocDefaults "><a href="#_Toc532637373"><span class="Hyperlink DefaultParagraphFont " style="">Field background</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637373"><span>1</span></a></a></p>
  
  <p class="TOC2 Normal DocDefaults "><a href="#_Toc532637374"><span class="Hyperlink DefaultParagraphFont " style="">TOC Content Control</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637374"><span>1</span></a></a></p>
  
  <p class="TOC2 Normal DocDefaults "><a href="#_Toc532637375"><span class="Hyperlink DefaultParagraphFont " style="">TOC Field Syntax</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637375"><span>1</span></a></a></p>
  
  <p class="TOC2 Normal DocDefaults "><a href="#_Toc532637376"><span class="Hyperlink DefaultParagraphFont " style="">Inserting/generating a TOC</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637376"><span>1</span></a></a></p>
  
  <p class="TOC2 Normal DocDefaults "><a href="#_Toc532637377"><span class="Hyperlink DefaultParagraphFont " style="">Page Number Considerations</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637377"><span>1</span></a></a></p>
  
  <p class="TOC2 Normal DocDefaults "><a href="#_Toc532637378"><span class="Hyperlink DefaultParagraphFont " style="">Updating a TOC</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637378"><span>1</span></a></a></p>
  
  <p class="TOC2 Normal DocDefaults "><a href="#_Toc532637379"><span class="Hyperlink DefaultParagraphFont " style="">Known Issues</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637379"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637380"><span class="Hyperlink DefaultParagraphFont " style="">Text extraction</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637380"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637381"><span class="Hyperlink DefaultParagraphFont " style="">Text substitution</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637381"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637382"><span class="Hyperlink DefaultParagraphFont " style="">Text substitution via data bound content controls</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637382"><span>1</span></a></a></p>
  
  <p class="TOC2 Normal DocDefaults "><a href="#_Toc532637383"><span class="Hyperlink DefaultParagraphFont " style="">Binding extensions for repeats and conditionals</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637383"><span>1</span></a></a></p>
  
  <p class="TOC2 Normal DocDefaults "><a href="#_Toc532637384"><span class="Hyperlink DefaultParagraphFont " style="">Binding escaped XHTML (XML + CSS)</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637384"><span>1</span></a></a></p>
  
  <p class="TOC2 Normal DocDefaults "><a href="#_Toc532637385"><span class="Hyperlink DefaultParagraphFont " style="">Binding other rich content</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637385"><span>1</span></a></a></p>
  
  <p class="TOC2 Normal DocDefaults "><a href="#_Toc532637386"><span class="Hyperlink DefaultParagraphFont " style="">Authoring</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637386"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637387"><span class="Hyperlink DefaultParagraphFont " style="">Mailmerge</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637387"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637388"><span class="Hyperlink DefaultParagraphFont " style="">SmartArt</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637388"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637389"><span class="Hyperlink DefaultParagraphFont " style="">JAXB stuff</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637389"><span>1</span></a></a></p>
  
  <p class="TOC2 Normal DocDefaults "><a href="#_Toc532637390"><span class="Hyperlink DefaultParagraphFont " style="">Cloning</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637390"><span>1</span></a></a></p>
  
  <p class="TOC2 Normal DocDefaults "><a href="#_Toc532637391"><span class="Hyperlink DefaultParagraphFont " style="">javax.xml.bind.JAXBElement</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637391"><span>1</span></a></a></p>
  
  <p class="TOC2 Normal DocDefaults "><a href="#_Toc532637392"><span class="Hyperlink DefaultParagraphFont " style="">@XmlRootElement</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637392"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637393"><span class="Hyperlink DefaultParagraphFont " style="">Merging Documents and Presentations</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637393"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637394"><span class="Hyperlink DefaultParagraphFont " style="">Other Support Options</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637394"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637395"><span class="Hyperlink DefaultParagraphFont " style="">Colophon</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637395"><span>1</span></a></a></p>
  
  <p class="TOC1 Normal DocDefaults "><a href="#_Toc532637396"><span class="Hyperlink DefaultParagraphFont " style="">Contacting Plutext</span><span class="DefaultParagraphFont ">   </span><a href="#_Toc532637396"><span>1</span></a></a></p>
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="font-weight: bold;" /></p>
  
  <p class="Normal DocDefaults "> </p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">This guide is for docx4j </span><span class="DefaultParagraphFont " style="font-weight: bold;">8.0.0</span><span class="" style="">.</span><span class="" style="white-space:pre-wrap;">  The </span><span class="" style="">8.x series will be the last series to run under Java 1.8</span><span class="" style="white-space:pre-wrap;"> (hence the name). </span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">There are 2 significant changes in docx4j 8.0.0:</span></p><ol>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">The project is now structured as a maven multi-module project</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">You'll need one and only one of the docx4j-JAXB-</span><span style="">[</span><span style="">Internal|MOXy|ReferenceImpl</span><span style="white-space:pre-wrap;">] </span><span style="">artifacts</span><span style="white-space:pre-wrap;"> </span><span style="white-space:pre-wrap;">and its deps</span></li></ol>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">The latest version of this document can always be found in </span><a href="https://github.com/plutext/docx4j/tree/master/docs"><span class="Hyperlink DefaultParagraphFont " style="">docx4j on GitHub in /docs</span></a><span class="" style="white-space:pre-wrap;" /><span class="" style="">.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">There is also a handy 1 page summary at </span><a href="https://www.docx4java.org/docx4j/plutext-docx4j_on_a_page-v300.pdf"><span class="Hyperlink DefaultParagraphFont " style="">https://www.docx4java.org/docx4j/plutext-docx4j_on_a_page-v300.pdf</span></a><span class="" style="white-space:pre-wrap;"> </span><span class="" style="">(look out for an update soon).</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">The most up to date copy of this document is in English.  There is also a Russian version.  From time to time, it may be machine translated into other languages.  Please let us know if you are interested in writing some basic documentation in your own language (either as a contribution, or for a fee). </span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637325" /><span style="">What is docx4j?</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">docx4j is a library for </span><span class="" style="">working with docx, pptx and xlsx files in Java.  In essence, it can unzip a</span><span class="" style="white-space:pre-wrap;"> docx </span><span class="" style="">(or pptx/xlsx) "package", and parse</span><span class="" style="white-space:pre-wrap;"> the XML to create an in-memory representation in </span><span class="" style="">Java</span><span class="" style="white-space:pre-wrap;"> using developer friendly classes (as opposed to DOM or SAX).  </span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">docx4j is usually deployed as part of a web application (eg</span><span class="" style="white-space:pre-wrap;"> on Tomcat, JBOSS, WebSphere etc </span><span class="" style="">– </span><span class="" style="white-space:pre-wrap;">see the deployment forums).</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">docx4j</span><span class="" style="white-space:pre-wrap;"> is similar in concept to Microsoft's  </span><span class="" style="">OpenXML</span><span class="" style="white-space:pre-wrap;"> SDK, which is for .NET.  docx4j.NET is available for the NET platform; see further below.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">A distinctive strength of docx4j is that its in-memory representation uses </span><span class="DefaultParagraphFont " style="font-weight: bold;">JAXB</span><span class="" style="white-space:pre-wrap;">, the JCP standard for Java - XML binding.  Docx4j is the only library for working with </span><span class="" style="">OpenXML</span><span class="" style="white-space:pre-wrap;"> files which uses/supports JAXB (</span><span class="" style="">each of</span><span class="" style="white-space:pre-wrap;"> the Sun/Oracle</span><span class="" style="">,</span><span class="" style="white-space:pre-wrap;"> </span><span class="" style="">MOXy</span><span class="" style="white-space:pre-wrap;"> </span><span class="" style="">and IBM</span><span class="FootnoteReference DefaultParagraphFont " style="vertical-align: top; font-size: xx-small"><a name="fs1"><a href="#fn1">1</a></a></span><span class="" style="white-space:pre-wrap;"> implementations).  </span><span class="" style="">In contrast, Apache POI uses XML Beans.</span><span class="" style="white-space:pre-wrap;">  (</span><span class="" style="">Aspose</span><span class="" style="white-space:pre-wrap;"> in contrast, does not provide low-level access to the underlying XML or a corresponding object model, so "you can't do it" unless </span><span class="" style="">Aspose</span><span class="" style="white-space:pre-wrap;"> provides support for it).  </span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">docx4j is open source, available under the Apache License (v2).  As an open source project, docx4j has been substantially improved by a number of contributions (see the README or POM file for contributors), and further contributions are always welcome.  Please see the docx4j forum at </span><a href="http://www.docx4java.org/forums/"><span class="DefaultParagraphFont " style="color: #0000FF;text-decoration: underline;">http://</span><span class="DefaultParagraphFont " style="color: #0000FF;text-decoration: underline;">www.docx4java</span><span class="DefaultParagraphFont " style="color: #0000FF;text-decoration: underline;">.org/forums/</span></a><span class="" style="white-space:pre-wrap;"> for details.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">The docx4j project is sponsored by Plutext (</span><a href="http://www.plutext.com"><span class="Hyperlink DefaultParagraphFont " style="">www.plutext.com</span></a><span class="" style="">).</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">There is also a commercial enterprise edition of docx4j, which comes with commercial support and additional functionality not found in the community edition.  Additional functionality includes:</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">Merging documents or presentations</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">OLE embedding of files in docx, pptx, xlsx</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">Digital signatures</span></li></ul>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637326" /><span style="">What sorts of things can you do with docx4j?</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">Open existing docx (from filesystem, SMB/CIFS, WebDAV using VFS), pptx, xlsx</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">Create new docx, pptx, xlsx</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">Programmatically manipulate the above (of course)</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">Save to various media zipped, or unzipped</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">Protection settings</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">Produce/consume  the Flat OPC XML format</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">Do all this on Android.</span></li></ul>
  
  <p class="Normal DocDefaults "><span class="" style="">Specific to docx4j (as opposed to pptx4j, xlsx4j):</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">Import XHTML</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">Export as (X)HTML or PDF</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="white-space:pre-wrap;">Template substitution; </span><span style="">CustomXML</span><span style="white-space:pre-wrap;"> </span><span style="white-space:pre-wrap;">binding</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">Mail merge</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">Apply transforms, including common filters</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="white-space:pre-wrap;">Diff/compare documents, paragraphs or </span><span style="">sdt</span><span style="white-space:pre-wrap;"> </span><span style="white-space:pre-wrap;">(content controls)</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">Font support (font substitution, and use of any fonts embedded in the document)</span></li></ul>
  
  <p class="Normal DocDefaults "><span class="" style="">This document focuses primarily on docx4j, but the general principles are equally applicable to pptx4j and xlsx4j.</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637327" /><span style="">Is docx4j for you?</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Docx4j is for processing docx documents (and pptx presentations and xlsx spreadsheets) in Java.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">It isn't for old binary (.doc) files.  If you wish to invest your effort around docx (as is wise), but you also need to be able to handle old doc files, see further below for your options. </span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Nor is it for RTF files.</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637328" /><span style="">GraalVM</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Programs based on docx4j can be converted to a </span><span class="" style="">Graal</span><span class="" style="white-space:pre-wrap;"> native image, and run "serverless" on AWS Lambda.</span></p>
  
  <p class="Heading1 Normal DocDefaults "><span class="" style="">docx4j.NET</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">If you want to process docx/pptx/xslsx</span><span class="" style="white-space:pre-wrap;"> on the .NET platform, you should </span><span class="" style="">consider</span><span class="" style="white-space:pre-wrap;"> Microsoft's </span><span class="" style="">OpenXML</span><span class="" style="white-space:pre-wrap;"> SDK.  That said, docx4j can be used in a .NET environment via IKVM, and there are several reasons you might wish to do this:</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">Where you need docx4j</span><span>’</span><span style="">s capabilities, for example:</span></li><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">XHTML import</span><span style="">/export/roundtrip</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">PDF export</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">OpenDoPE</span><span style="white-space:pre-wrap;"> </span><span style="white-space:pre-wrap;">processing</span></li></ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="white-space:pre-wrap;">Capabilities provided by docx4j </span><span style="">enterprise edition (as to which see above)</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">Where you need to work in both Java and .NET, and want to use a single API in both environments</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="white-space:pre-wrap;">Where you need the source code (Microsoft doesn</span><span>’</span><span style="white-space:pre-wrap;">t </span><span style="">provide that)</span></li></ul>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">You can use docx4j.NET and the </span><span class="" style="">OpenXML</span><span class="" style="white-space:pre-wrap;"> SDK together; see </span><a href="https://github.com/plutext/docx4j.NET/blob/master/docx4j.NET/src/samples/c%23/Docx4NET/InteropDocx.cs"><span class="Hyperlink DefaultParagraphFont " style="">InteropDocx</span></a><span class="" style="white-space:pre-wrap;" /></p>
  
  <p class="Normal DocDefaults "><span class="" style="">As on the Java platform, docx4j.NET comes in community and commercial editions.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">See </span><a href="https://www.nuget.org/packages/docx4j.NET/"><span class="Hyperlink DefaultParagraphFont " style="">https://www.nuget.org/packages/docx4j.NET/</span></a><span class="" style="white-space:pre-wrap;" /></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637329" /><span style="">What Word documents does it support?</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Docx4j can read/write docx documents created by or for Word 2007</span><span class="" style="white-space:pre-wrap;"> or later, </span><span class="" style="">plus</span><span class="" style="white-space:pre-wrap;"> earlier versions which have the compatibility pack installed. (Same goes for xlsx spreadsheets and pptx presentations).</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">The relevant parts of docx4j are generated from the ECMA schemas</span><span class="" style="white-space:pre-wrap;">, with the addition of the key </span><span class="" style="">Microsoft proprietary extensions.</span><span class="" style="white-space:pre-wrap;">  For unsupported extensions, docx4j gracefully degrades to the specified 2007 substitutes.</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="" style="white-space:pre-wrap;">It </span><span class="" style="">is not really intended</span><span class="" style="white-space:pre-wrap;"> read/write Word 2003 XML documents, although </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">package</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> org.docx4j.convert.in.word2003xml </span></span><span class="" style="">is a proof of concept of importing such documents.</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">For more information, please see </span><a href="#_Ref280708892"><span class="DefaultParagraphFont " style="font-weight: bold;font-style: italic;">Specification versions</span></a><span class="" style="white-space:pre-wrap;"> below.</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637330" /><span style="">Handling legacy binary .doc files</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">An effective approach is to use LibreOffice or OpenOffice (via </span><span class="" style="">jodconverter</span><span class="" style="white-space:pre-wrap;">) to convert the doc to docx, which docx4j can then process.  If you need to return a binary .doc, LibreOffice or </span><span class="" style="">OpenOffice/jodconverter</span><span class="" style="white-space:pre-wrap;"> can convert the docx back to .doc.</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637331" /><span class="DefaultParagraphFont " style="">Getting Help: the docx4j forum</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Free community support is available in the docx4j forum, at </span><a href="http://www.docx4java.org/forums/"><span class="DefaultParagraphFont " style="color: #0000FF;text-decoration: underline;">http://www.docx4java.org/forums/</span></a><span class="" style="white-space:pre-wrap;" /><span class="DefaultParagraphFont " style="color: #0000FF;text-decoration: underline;;white-space:pre-wrap;"> </span><span class="" style="">and on Stack Overflow.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Before posting, please:</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">check this document doesn</span><span>’</span><span style="">t answer your question</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">try to help yourself: people are unlikely to help you if it looks like you are asking someone else to do lots of work you presumably are being paid to do!</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">ensure your post says which version of docx4j you are using, and contains your Java code (between [java] .. and .. [/java]) and XML (between [xml] .. and .. [/xml])</span><span style="">, and if appropriate a docx/pptx/xlsx attachment</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="white-space:pre-wrap;">consider browsing relevant docx4j source code </span></li></ul>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">This discussion is generally in English.  If you </span><span class="" style="">would like</span><span class="" style="white-space:pre-wrap;"> to moderate a forum in another language (for example, French, Chinese, Spanish</span><span class="" style="">…</span><span class="" style="white-space:pre-wrap;">), please let us know.</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637338" /><span style="white-space:pre-wrap;">A word about </span><span style="">Jaxb</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">docx4j uses JAXB to </span><span class="" style="">marshall</span><span class="" style="white-space:pre-wrap;"> and unmarshall the XML parts in a docx/pptx/xlsx.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Docx4j supports each of the 3 JAXB implementations:</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="white-space:pre-wrap;">the </span><span style="white-space:pre-wrap;">JAXB in Java 8 </span><span style="">implementation</span><span style="white-space:pre-wrap;">; to use this, you need the </span><span style="">docx4j-JAXB-Internal</span><span style="white-space:pre-wrap;"> </span><span style="white-space:pre-wrap;">jar. You can also use this with Java 9.  But not Java 11, since </span><span style="">Java 11 does not ship JAXB anymore.</span><span style="white-space:pre-wrap;"> </span><br /></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">the Sun/Oracle/"Reference" implementation</span><span style="white-space:pre-wrap;">; to use this you need </span><span style="">docx4j-JAXB-ReferenceImpl</span></li></ul>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;"><span class="" style="">You can also use the JAXB reference implementation (eg</span><span class="" style="white-space:pre-wrap;"> v2.2.4).  If you want to use that in preference to the version included in the JDK, do so using the endorsed directory mechanism.</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">Moxy</span><span style="white-space:pre-wrap;">.  To use this, you need </span><span style="">docx4j-JAXB-MOXy</span><span style="">.</span><br /></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="white-space:pre-wrap;">IBM's (in WebSphere).  </span><span style="white-space:pre-wrap;">By default, WebSphere uses com.ibm.xml.xlxp2.jaxb, which has the concept of fallback/ </span><span style="">MarshallerProxy</span><span style="">.  The actual implementation it uses is in com.ibm.jaxb.tools.jar.</span></li></ul>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637332" /><span style="">Using docx4j via Maven</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">docx4j is in Maven Central.  For Maven users, t</span><span class="" style="white-space:pre-wrap;">his makes it really easy to get going with docx4j.  </span></p>
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="white-space:pre-wrap;">To use docx4j 8.0.0, add </span><span class="" style="">one and only one of the</span><span class="" style="white-space:pre-wrap;"> following to your project:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;"><span class="DefaultParagraphFont " style="font-size: 8.0pt;">      <span class="" style="">&lt;</span>!-- use the JAXB shipped in Java 8 --&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;"><span class="DefaultParagraphFont " style="font-size: 8.0pt;">      <span class="" style="">&lt;dependency&gt;</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;"><span class="DefaultParagraphFont " style="font-size: 8.0pt;">         <span class="" style="">&lt;</span>groupId&gt;org.docx4j&lt;/groupId&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;"><span class="DefaultParagraphFont " style="font-size: 8.0pt;">         <span class="" style="">&lt;</span>artifactId&gt;</span><span class="DefaultParagraphFont " style="font-weight: bold;font-size: 8.0pt;">docx4j-JAXB-</span><span class="DefaultParagraphFont " style="font-weight: bold;font-size: 8.0pt;text-decoration: underline;">Internal</span><span class="DefaultParagraphFont " style="font-size: 8.0pt;">&lt;/artifactId&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;"><span class="DefaultParagraphFont " style="font-size: 8.0pt;">         <span class="" style="">&lt;version&gt;</span>8.0.0&lt;/version&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;"><span class="DefaultParagraphFont " style="font-size: 8.0pt;">      <span class="" style="">&lt;/dependency&gt;</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;"><span class="DefaultParagraphFont " style="font-size: 8.0pt;">      </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;"><span class="DefaultParagraphFont " style="font-size: 8.0pt;">      <span class="" style="white-space:pre-wrap;">&lt;!-- use the JAXB </span>Reference Implementation<span class="" style="white-space:pre-wrap;"> --&gt;</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;"><span class="DefaultParagraphFont " style="font-size: 8.0pt;">      <span class="" style="">&lt;dependency&gt;</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;"><span class="DefaultParagraphFont " style="font-size: 8.0pt;">         <span class="" style="">&lt;</span>groupId&gt;org.docx4j&lt;/groupId&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;"><span class="DefaultParagraphFont " style="font-size: 8.0pt;">         <span class="" style="">&lt;</span>artifactId&gt;</span><span class="DefaultParagraphFont " style="font-weight: bold;font-size: 8.0pt;">docx4j-JAXB-</span><span class="DefaultParagraphFont " style="font-weight: bold;font-size: 8.0pt;text-decoration: underline;">ReferenceImpl</span><span class="DefaultParagraphFont " style="font-size: 8.0pt;">&lt;/artifactId&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;"><span class="DefaultParagraphFont " style="font-size: 8.0pt;">         <span class="" style="">&lt;version&gt;8.0.0&lt;/version&gt;</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;"><span class="DefaultParagraphFont " style="font-size: 8.0pt;">      <span class="" style="">&lt;/dependency&gt;</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;"><span class="DefaultParagraphFont " style="font-size: 8.0pt;">      </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;"><span class="DefaultParagraphFont " style="font-size: 8.0pt;">      <span class="" style="white-space:pre-wrap;">&lt;!-- use the </span>MOXy</span><span class="DefaultParagraphFont " style="font-size: 8.0pt;;white-space:pre-wrap;"> JAXB </span><span class="DefaultParagraphFont " style="font-size: 8.0pt;">implementation<span class="" style="white-space:pre-wrap;"> --&gt;</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;"><span class="DefaultParagraphFont " style="font-size: 8.0pt;">      <span class="" style="">&lt;dependency&gt;</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;"><span class="DefaultParagraphFont " style="font-size: 8.0pt;">         <span class="" style="">&lt;</span>groupId&gt;org.docx4j&lt;/groupId&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;"><span class="DefaultParagraphFont " style="font-size: 8.0pt;">         <span class="" style="">&lt;</span>artifactId&gt;</span><span class="DefaultParagraphFont " style="font-weight: bold;font-size: 8.0pt;">docx4j-JAXB-</span><span class="DefaultParagraphFont " style="font-weight: bold;font-size: 8.0pt;text-decoration: underline;">MOXy</span><span class="DefaultParagraphFont " style="font-size: 8.0pt;">&lt;/artifactId&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;"><span class="DefaultParagraphFont " style="font-size: 8.0pt;">         <span class="" style="">&lt;version&gt;8.0.0&lt;/version&gt;</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;"><span class="DefaultParagraphFont " style="font-size: 8.0pt;">      <span class="" style="">&lt;/dependency&gt;</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;"> </p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">The blog entry </span><a href="http://www.docx4java.org/blog/2011/10/hello-maven-central/"><span class="Hyperlink DefaultParagraphFont " style="">hello-maven-central</span></a><span class="" style="white-space:pre-wrap;" /><span class="" style="">s</span><span class="" style="white-space:pre-wrap;"> [needs to be updated per above] s</span><span class="" style="">hows you what to do, starting with a fresh OS (Win 7 is used, but these steps would work equally well on OSX or Linux).</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637333" /><span style="">Using docx4j binaries</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">If Maven is not for you, y</span><span class="" style="white-space:pre-wrap;">ou can download the latest version of docx4j from </span><a href="http://www.docx4java.org/docx4j/"><span class="Hyperlink DefaultParagraphFont " style="">http://</span><span class="Hyperlink DefaultParagraphFont " style="">www.docx4java</span><span class="Hyperlink DefaultParagraphFont " style="">.org/docx4j/</span></a><span class="" style="white-space:pre-wrap;" /></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Supporting jars can be found in the .tar.gz or zip version, or in the relevant subdirectory.  </span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">You'll need the jars from one and only one of these directorie</span><span class="" style="white-space:pre-wrap;">s: </span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="white-space:pre-wrap;">docx4j-JAXB-Internal, </span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="white-space:pre-wrap;">docx4j-JAXB-ReferenceImpl, </span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">docx4j-JAXB-MOXy</span></li></ul>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637334" /><span style="">docx4j dependencies</span></p>
  
  <p class="Heading2 Normal DocDefaults "><a name="_Toc532637335" /><span style="">slf</span><span style="">4j</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">To do anything with docx4j, you need </span><span class="DefaultParagraphFont " style="font-weight: bold;">slf4j</span><span class="" style="white-space:pre-wrap;"> on your </span><span class="" style="">classpath.</span><span class="" style="white-space:pre-wrap;">  As the slf4j website puts it:</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;"><span class="DefaultParagraphFont " style="color: #777777;background-color: #FFFFFF;font-size: 10.0pt;;white-space:pre-wrap;">The Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction for various logging frameworks (e.g. </span><span class="DefaultParagraphFont " style="color: #777777;background-color: #FFFFFF;font-size: 10.0pt;">java.util.logging</span><span class="DefaultParagraphFont " style="color: #777777;background-color: #FFFFFF;font-size: 10.0pt;;white-space:pre-wrap;">, </span><span class="DefaultParagraphFont " style="color: #777777;background-color: #FFFFFF;font-size: 10.0pt;">logback<span class="" style="">, log4j) allowing the end user to plug in the desired logging framework at </span></span><span class="Emphasis DefaultParagraphFont " style="color: #777777;background-color: #FFFFFF;font-size: 10.0pt;">deployment</span><span class="apple-converted-space DefaultParagraphFont " style="color: #777777;background-color: #FFFFFF;font-size: 10.0pt;"> </span><span class="DefaultParagraphFont " style="color: #777777;background-color: #FFFFFF;font-size: 10.0pt;">time.</span></p>
  
  <p class="NormalWeb Normal DocDefaults " style="border-color: #FFFFFF; border-style:solid; border-width:1px;background-color: #FFFFFF;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;">So you need the slf4j </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">api</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;"> jar on your </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">classpath:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;">  &lt;</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">dependency</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;">    &lt;</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">groupId</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&gt;</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">org.slf4j</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&lt;/</span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">groupId</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;">    &lt;</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">artifactId</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&gt;</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">slf4j-api</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&lt;/</span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">artifactId</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;">    &lt;</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">version</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&gt;</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">1.7.5</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&lt;/</span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">version</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;">  &lt;/</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">dependency</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&gt;</span></p>
  
  <p class="NormalWeb Normal DocDefaults " style="border-color: #FFFFFF; border-style:solid; border-width:1px;background-color: #FFFFFF;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;">If you want to use </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">logback, then include it:</span></p>
  
  <p class="NormalWeb Normal DocDefaults " style="border-color: #FFFFFF; border-style:solid; border-width:1px;background-color: #FFFFFF;margin-top: 0in;margin-bottom: 0in;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.5pt;">   <span class="" style="">&lt;dependency&gt;</span></span></p>
  
  <p class="NormalWeb Normal DocDefaults " style="border-color: #FFFFFF; border-style:solid; border-width:1px;background-color: #FFFFFF;margin-top: 0in;margin-bottom: 0in;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.5pt;">   <span class="" style="white-space:pre-wrap;">  &lt;</span>groupId&gt;ch.qos.logback&lt;/groupId&gt;</span></p>
  
  <p class="NormalWeb Normal DocDefaults " style="border-color: #FFFFFF; border-style:solid; border-width:1px;background-color: #FFFFFF;margin-top: 0in;margin-bottom: 0in;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.5pt;">   <span class="" style="white-space:pre-wrap;">  &lt;</span>artifactId&gt;logback-classic&lt;/artifactId&gt;</span></p>
  
  <p class="NormalWeb Normal DocDefaults " style="border-color: #FFFFFF; border-style:solid; border-width:1px;background-color: #FFFFFF;margin-top: 0in;margin-bottom: 0in;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.5pt;">   <span class="" style="white-space:pre-wrap;">  &lt;version&gt;1.3.0-alpha4&lt;/version&gt;</span></span></p>
  
  <p class="NormalWeb Normal DocDefaults " style="border-color: #FFFFFF; border-style:solid; border-width:1px;background-color: #FFFFFF;margin-top: 0in;margin-bottom: 0in;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.5pt;">   <span class="" style="">&lt;/dependency&gt;</span></span></p>
  
  <p class="NormalWeb Normal DocDefaults " style="border-color: #FFFFFF; border-style:solid; border-width:1px;background-color: #FFFFFF;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">If you want to use log4j, then include it, and:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;">  &lt;</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">dependency</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;">    &lt;</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">groupId</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&gt;</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">org.slf4j</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&lt;/</span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">groupId</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;">    &lt;</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">artifactId</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&gt;</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">slf4j-log4j12</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&lt;/</span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">artifactId</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;">    &lt;</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">version</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&gt;</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">1.7.5</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&lt;/</span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">version</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;">  &lt;/</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">dependency</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&gt;</span></p>
  
  <p class="Heading2 Normal DocDefaults "><a name="_Toc532637336" /><span style="">other dependencies</span><span style="white-space:pre-wrap;"> </span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Depending what you want to do, the other</span><span class="" style="white-space:pre-wrap;"> dependencies will be required.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Best practice is to include all dependencies on your class path, and be done with it.  </span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">In your development environment, you can do this using Maven, or by physically copying them all to your </span><span class="" style="">classpath.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">For your deployment environment, your build process ought to be set up to do this for you.</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637339" /><span style="">Docx4j source code</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Docx4j</span><span class="" style="white-space:pre-wrap;"> source is on GitHub at </span><a href="https://github.com/plutext/docx4j"><span class="Hyperlink DefaultParagraphFont " style="">https://github.com/plutext/docx4j</span></a><span class="" style="white-space:pre-wrap;"> .  </span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">We accept pull requests; pull requests are presumed to be contributions under ASLv2 per our contributor agreement.  </span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">See </span><a href="http://www.docx4java.org/blog/2012/05/docx4j-from-github-in-eclipse/"><span class="Hyperlink DefaultParagraphFont " style="">docx4j-from-github-in-eclipse</span></a><span class="" style="white-space:pre-wrap;"> for details.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Source code can also be downloaded from Maven Central (search for docx4j at search.maven.org).</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637340" /><span style="">Javadoc</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Javadoc can be downloaded from Maven Central (search for docx4j at search.maven.org), but you’ll find the source code much more useful!  See above.</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637341" /><span style="">Building docx4j from source</span><span style="white-space:pre-wrap;"> </span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Get the source code from GitHub (see above), then…</span><span class="" style="white-space:pre-wrap;"> (you probably want to skip down to the next page, to get it working in Eclipse).</span></p>
  
  <p class="Heading2 Normal DocDefaults "><a name="_Toc532637342" /><span style="">Command line -via Maven</span></p>
  
  <p class="Command NormalWeb Normal DocDefaults "><span class="apple-style-span DefaultParagraphFont " style="color: #000000;">export MAVEN_OPTS=-Xmx512m</span><span class="DefaultParagraphFont " style="color: #000000;"><br /></span><span class="" style="">mvn</span><span class="" style="white-space:pre-wrap;"> install </span></p>
  
  <p class="Heading2 Normal DocDefaults " style="page-break-after: avoid;"><a name="_Toc532637344" /><span style="">Eclipse</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">See </span><a href="http://www.docx4java.org/blog/2012/05/docx4j-from-github-in-eclipse/"><span class="Hyperlink DefaultParagraphFont " style="">docx4j-from-github-in-eclipse</span></a><span class="" style="white-space:pre-wrap;" /><span class="" style="">.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Not working?</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Enable Maven (make sure you have Maven and its plugin installed - see Prerequisites above):</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">with Eclipse Indigo</span></li><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">Right click on the project</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">Click "Configure &gt; Convert to Maven Project"</span></li></ul></ul>
  
  <p class="Normal DocDefaults "><span class="" style="">compiler version &amp; system library:</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">Right click on the project (or Alt-Enter)</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">Choose "Java Compiler", then set JDK compliance to 1.</span><span style="">8</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">Choose "Java Build Path", and check you are using 1.</span><span style="">8</span><span style="white-space:pre-wrap;"> </span><span style="white-space:pre-wrap;">"JRE System Library". If not, remove, then click "Add Library"</span></li></ul>
  
  <p class="Normal DocDefaults "><span class="" style="">The project should now be working in Eclipse without errors</span><span class="FootnoteReference DefaultParagraphFont " style="vertical-align: top; font-size: xx-small"><a name="fs2"><a href="#fn2">2</a></a></span><span class="" style="white-space:pre-wrap;">. </span></p>
  
  <p class="Heading2 Normal DocDefaults "><a name="_Toc532637345" /><span style="">Using a different IDE?</span></p>
  
  <p class="Normal DocDefaults "><span class="underline DefaultParagraphFont " style="">Please post setup instructions in the forum, or as a wiki page on GitHub.  Thanks!</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637346" /><span class="DefaultParagraphFont " style="">Open an existing docx/pptx/xlsx document</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><a href="http://dev.plutext.org/trac/docx4j/trac/docx4j/browser/trunk/docx4j/src/main/java/org/docx4j/openpackaging/packages/WordprocessingMLPackage.java"><span class="DefaultParagraphFont " style="">org.docx4j.openpackaging.packages.</span><span class="DefaultParagraphFont " style="font-weight: bold;">WordprocessingMLPackage</span></a><span style=""> represents a docx document.</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">To load a document</span><span class="" style="white-space:pre-wrap;"> or </span><span class="" style="">“</span><span class="" style="white-space:pre-wrap;">Flat OPC</span><span class="" style="">” </span><span class="" style="white-space:pre-wrap;">XML file</span><span class="" style="">, all you have to do is:</span></p>
  
  <p class="Command NormalWeb Normal DocDefaults " style="position: relative; margin-left: 0in;">   <span style="">WordprocessingMLPackage</span><span style="white-space:pre-wrap;"> </span><span style="">wordMLPackage</span><span style="white-space:pre-wrap;"> = </span><br />      <span style="">WordprocessingMLPackage.load</span><span style="white-space:pre-wrap;">(new </span><span style="">java.io.File</span><span style="">(</span><span style="">inputfilepath</span><span style="">));</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">You can use the façade:</span></p>
  
  <p class="Command NormalWeb Normal DocDefaults " style="position: relative; margin-left: 0in;">   <span style="">WordprocessingMLPackage</span><span style="white-space:pre-wrap;"> </span><span style="">wordMLPackage</span><span style="white-space:pre-wrap;"> = </span><br />      <span class="DefaultParagraphFont " style="font-weight: bold;">Docx4J</span><span style="white-space:pre-wrap;">.load(new </span><span style="">java.io.File</span><span style="">(</span><span style="">inputfilepath</span><span style="">));</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">which does the same thing under the covers.</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="white-space:pre-wrap;">There are similar signatures to load from an input stream.  </span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">You can then get the main document part (word/document.xml):</span></p>
  
  <p class="Command NormalWeb Normal DocDefaults "><a href="http://dev.plutext.org/trac/docx4j/trac/docx4j/browser/trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/WordprocessingML/MainDocumentPart.java"><span class="DefaultParagraphFont " style="">MainDocumentPart</span></a><span style=""> </span><span style="">documentPart</span><span style="white-space:pre-wrap;"> = </span><span style="">wordMLPackage.getMainDocumentPart</span><span style="">();</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="white-space:pre-wrap;">After that, you can manipulate its contents. </span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">A similar approach works for pptx files:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   PresentationMLPackage</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">presentationMLPackage<span class="" style="white-space:pre-wrap;"> = </span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">      <span class="" style="">(</span>PresentationMLPackage)OpcPackage.</span><span class="DefaultParagraphFont " style="color: #000000;font-style: italic;font-size: 8.0pt;">load</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">(</span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">new</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">java.io.File(inputfilepath));</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">And similarly for xlsx files.</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637347" /><span style="">OpenXML</span><span style="white-space:pre-wrap;"> </span><span style="white-space:pre-wrap;">concepts</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">To do anything much beyond this, you need to have an understanding of basic </span><span class="" style="">WordML</span><span class="" style="white-space:pre-wrap;"> concepts (or </span><span class="" style="">PresentationML</span><span class="" style="white-space:pre-wrap;"> or </span><span class="" style="">SpreadsheetML).</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">According to the Microsoft Open Packaging spec, each docx document is made up of a number of </span><span class="" style="">“</span><span class="" style="white-space:pre-wrap;">Part</span><span class="" style="">” </span><span class="" style="white-space:pre-wrap;">files, zipped up.  </span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">An easy way to get an understanding of this is to unzip a docx/pptx/xlsx using your favourite zip utility.  Even easier is to visit </span><a href="http://webapp.docx4java.org"><span class="Hyperlink DefaultParagraphFont " style="">http://webapp.docx4java.org</span></a><span class="" style="white-space:pre-wrap;">  and explore your file using </span><span class="" style="">“PartsList”.  You can also generate code that way.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">A Part is usually XML, but might not be (an image part, for example, isn't).</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">The parts form a tree. If a part has child parts, it must have a relationships part which identifies these.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">The part which contains the main text of the document is the Main Document Part.  Each Part has a name.  The name of the Main Document Part is usually "/word/document.xml".</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">If the document has a header, then the main document part </span><span class="" style="">woud</span><span class="" style="white-space:pre-wrap;"> have a header child part, and this would be described in the main document part's relationships (part).</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Similarly for any images.  To see the structure of any given document, </span><a href="http://webapp.docx4java.org/OnlineDemo/PartsList.html"><span class="Hyperlink DefaultParagraphFont " style="white-space:pre-wrap;">upload it to the </span><span class="Hyperlink DefaultParagraphFont " style="">PartsList</span><span class="Hyperlink DefaultParagraphFont " style="white-space:pre-wrap;"> </span><span class="Hyperlink DefaultParagraphFont " style="">webapp</span></a><span class="" style="white-space:pre-wrap;">, or run the "Parts List" sample (see </span><span class="" style="">further below).</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">An introduction to </span><span class="" style="">WordML</span><span class="" style="white-space:pre-wrap;"> is beyond the scope of this document.  You can find a very readable introduction in 1</span><span class="DefaultParagraphFont " style="vertical-align: super;font-size: smaller;">st</span><span class="" style="white-space:pre-wrap;"> edition Part 3 (Primer) at </span><a href="http://www.ecma-international.org/publications/standards/Ecma-376.htm"><span class="DefaultParagraphFont " style="color: #0000FF;text-decoration: underline;">http://www.ecma-international.org/publications/standards/Ecma-376.htm</span></a><span class="" style="white-space:pre-wrap;"> or </span><a href="http://www.ecma-international.org/news/TC45_current_work/TC45_available_docs.htm"><span class="DefaultParagraphFont " style="color: #0000FF;text-decoration: underline;">http://www.ecma-international.org/news/TC45_current_work/TC45_available_docs.htm</span></a><span class="" style="white-space:pre-wrap;"> (a better link for the 1st edition (Dec 2006), since </span><span class="" style="">its</span><span class="" style="white-space:pre-wrap;"> not zipped up). </span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">See also the free </span><a href="http://openxmldeveloper.org/cfs-file.ashx/__key/communityserver-components-postattachments/00-00-00-19-70/Open-XML-Explained.pdf"><span class="Hyperlink DefaultParagraphFont " style="white-space:pre-wrap;">"Open XML Explained" </span><span class="Hyperlink DefaultParagraphFont " style="">ebook</span></a><span class="" style="white-space:pre-wrap;"> by </span><span class="" style="">Wouter</span><span class="" style="white-space:pre-wrap;"> Van </span><span class="" style="">Vugt</span><span class="" style="white-space:pre-wrap;">.  </span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Ref280708892" /><a name="_Toc532637348" /><span class="DefaultParagraphFont " style="">Specification versions</span><span class="DefaultParagraphFont " style="white-space:pre-wrap;"> </span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">From Wikipedia:</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;"><span class="apple-style-span DefaultParagraphFont " style="color: #000000;">The</span><span class="apple-converted-space DefaultParagraphFont " style="color: #000000;"> </span><a alt="Office Open XML" href="http://en.wikipedia.org/wiki/Office_Open_XML"><span class="Hyperlink DefaultParagraphFont " style="color: #0645AD;">Office Open XML</span></a><span class="apple-converted-space DefaultParagraphFont " style="color: #000000;"> </span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;;white-space:pre-wrap;">file formats were standardised between December 2006 and November 2008, </span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 1in;"><span class="apple-style-span DefaultParagraphFont " style="color: #000000;">first by the</span><span class="apple-converted-space DefaultParagraphFont " style="color: #000000;"> </span><a alt="Ecma International" href="http://en.wikipedia.org/wiki/Ecma_International"><span class="Hyperlink DefaultParagraphFont " style="color: #0645AD;">Ecma</span><span class="Hyperlink DefaultParagraphFont " style="color: #0645AD;"><span class="" style="white-space:pre-wrap;"> International</span></span></a><span class="apple-converted-space DefaultParagraphFont " style="color: #000000;"> </span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;">consortium (where they became</span><span class="apple-converted-space DefaultParagraphFont " style="color: #000000;"> </span><span class="apple-style-span DefaultParagraphFont " style="font-weight: bold;color: #000000;">ECMA-376</span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;;white-space:pre-wrap;">), </span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 1in;"><span class="apple-style-span DefaultParagraphFont " style="color: #000000;">and subsequently .. by the</span><span class="apple-converted-space DefaultParagraphFont " style="color: #000000;"> </span><a alt="International Organization for Standardization" href="http://en.wikipedia.org/wiki/International_Organization_for_Standardization"><span class="Hyperlink DefaultParagraphFont " style="color: #0645AD;">ISO</span></a><span class="apple-converted-space DefaultParagraphFont " style="color: #000000;" /><span class="apple-style-span DefaultParagraphFont " style="color: #000000;">/</span><a alt="International Electrotechnical Commission" href="http://en.wikipedia.org/wiki/International_Electrotechnical_Commission"><span class="Hyperlink DefaultParagraphFont " style="color: #0645AD;">IEC</span></a><span class="apple-style-span DefaultParagraphFont " style="color: #000000;">'s</span><span class="apple-converted-space DefaultParagraphFont " style="color: #000000;"> </span><a alt="International Organization for Standardization" href="http://en.wikipedia.org/wiki/International_Organization_for_Standardization#ISO.2FIEC_Joint_Technical_Committee_1"><span class="Hyperlink DefaultParagraphFont " style="color: #0645AD;">Joint Technical Committee 1</span></a><span class="apple-converted-space DefaultParagraphFont " style="color: #000000;"> </span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;">(where they became</span><span class="apple-converted-space DefaultParagraphFont " style="color: #000000;"> </span><span class="apple-style-span DefaultParagraphFont " style="font-weight: bold;color: #000000;">ISO/IEC 29500:2008</span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;">).</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">The Ecma-376.htm link also contains the 2nd edition documents (of Dec 2008), which are </span><span class="apple-converted-space DefaultParagraphFont " style="color: #333333;">"</span><span class="apple-style-span DefaultParagraphFont " style="color: #333333;">technically aligned with ISO/IEC 29500".</span></p>
  
  <p class="Normal DocDefaults "><span class="apple-style-span DefaultParagraphFont " style="color: #333333;">Office 2007 SP2 implements ECMA-376 1st Edition</span><span class="FootnoteReference DefaultParagraphFont " style="color: #333333;;vertical-align: top; font-size: xx-small"><a name="fs3"><a href="#fn3">3</a></a></span><span class="apple-style-span DefaultParagraphFont " style="color: #333333;;white-space:pre-wrap;">; this is what docx4j </span><span class="apple-style-span DefaultParagraphFont " style="color: #333333;">started with</span></p>
  
  <p class="Normal DocDefaults "><span class="apple-style-span DefaultParagraphFont " style="color: #333333;">ISO/IEC 29500 (ECMA-376 2nd Edition) has</span><span class="apple-converted-space DefaultParagraphFont " style="color: #333333;"> </span><span class="apple-style-span DefaultParagraphFont " style="color: #333333;font-style: italic;">Strict</span><span class="apple-converted-space DefaultParagraphFont " style="color: #333333;"> </span><span class="apple-style-span DefaultParagraphFont " style="color: #333333;">and</span><span class="apple-converted-space DefaultParagraphFont " style="color: #333333;"> </span><span class="apple-style-span DefaultParagraphFont " style="color: #333333;font-style: italic;;white-space:pre-wrap;">Transitional </span><span class="apple-style-span DefaultParagraphFont " style="color: #333333;">conformance classes.  Office 2010 supports</span><span class="FootnoteReference DefaultParagraphFont " style="color: #333333;;vertical-align: top; font-size: xx-small"><a name="fs4"><a href="#fn4">4</a></a></span><span class="apple-style-span DefaultParagraphFont " style="color: #333333;"><span class="" style="white-space:pre-wrap;"> transitional, and also has read only support for strict.</span></span></p>
  
  <p class="Normal DocDefaults "><span class="apple-style-span DefaultParagraphFont " style="color: #333333;">docx4j started with</span><span class="apple-style-span DefaultParagraphFont " style="color: #333333;;white-space:pre-wrap;"> </span><span class="apple-style-span DefaultParagraphFont " style="color: #333333;">ECMA-376 1st Edition.<span class="" style="white-space:pre-wrap;">  Where appropriate later versions of the schemas are used.  docx4j 3.0 uses MathML 2ed, </span>PresentationML<span class="" style="white-space:pre-wrap;"> 2ed, and </span>SpreadsheemML<span class="" style="white-space:pre-wrap;"> 4ed transitional.</span></span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Docx4j can open documents which contain Word 2010, 2013</span><span class="" style="white-space:pre-wrap;"> specific </span><span class="" style="">content.</span><span class="" style="white-space:pre-wrap;">  The key extensions are supported.  For other stuff, for example,  &lt;w14:glow w14:rad="101600"&gt;  it will look for and try to use </span><span class="" style="">mc:AlternateContent</span><span class="" style="white-space:pre-wrap;"> contained in the document.  If you use docx4j to save the document, the w14:glow won</span><span class="" style="">’</span><span class="" style="white-space:pre-wrap;">t be there any more (</span><span class="" style="">ie</span><span class="" style="white-space:pre-wrap;"> the docx will effectively be a Word 2007 docx).</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637349" /><span class="DefaultParagraphFont " style="">Architecture</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Docx4j has 3 layers:</span></p><ol>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span class="DefaultParagraphFont " style="font-weight: bold;">org.docx4j.openpackaging</span><br /><br /><span style="">OpenPackaging</span><span style="white-space:pre-wrap;"> </span><span style="white-space:pre-wrap;">handles things at the O</span><span style="">pen Packaging Conventions level.</span><span style="white-space:pre-wrap;"> </span><br /><br /><span style="">It includes objects corresponding to each Office file type</span><span style="">:</span></li></ol>
  
  <p class="ListParagraph Normal DocDefaults "> </p>
  
  <table class="TableGrid TableNormal " id="docx4j_tbl_0" style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;position: relative; margin-left: 19mm;table-layout: fixed;vertical-align: top;border-collapse: collapse;width: 5.89in;"><colgroup><col style="width: 21.73%;" /><col style="width: 78.27%;" /></colgroup><tbody><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="ListParagraph-TableGrid-BR DocDefaults " style="position: relative; margin-left: 0in;"><span class="" style="">docx</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="ListParagraph-TableGrid-BR DocDefaults " style="position: relative; margin-left: 0in;"><span class="DefaultParagraphFont " style="">org.docx4j.openpackaging.packages.</span><span class="DefaultParagraphFont " style="font-weight: bold;">WordprocessingMLPackage</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="ListParagraph-TableGrid-BR DocDefaults " style="position: relative; margin-left: 0in;"><span class="" style="">pptx</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="ListParagraph-TableGrid-BR DocDefaults " style="position: relative; margin-left: 0in;"><span class="" style="">org.docx4j.openpackaging.packages.</span><span class="DefaultParagraphFont " style="font-weight: bold;">PresentationMLPackage</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="ListParagraph-TableGrid-BR DocDefaults " style="position: relative; margin-left: 0in;"><span class="" style="">xlsx</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="ListParagraph-TableGrid-BR DocDefaults " style="position: relative; margin-left: 0in;"><span class="" style="">org.docx4j.openpackaging.packages.</span><span class="DefaultParagraphFont " style="font-weight: bold;">SpreadsheetMLPackage</span></p></td></tr></tbody></table>
  
  <p class="ListParagraph Normal DocDefaults "> </p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;"><span class="" style="white-space:pre-wrap;">and is responsible for unzipping the file into a set of objects inheriting from Part;  </span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;"><span class="DefaultParagraphFont " style="font-weight: bold;">openpackaging</span><span class="" style="white-space:pre-wrap;"> also includes </span><span class="" style="">functionalitiy</span><span class="" style="white-space:pre-wrap;"> </span><span class="" style="">allowing parts to be added/deleted; saving the docx/pptx/xlsx etc</span><br /><span class="" style="" /><br /><span class="" style="" /><span class="" style="white-space:pre-wrap;">This layer is based originally on OpenXML4J (which is also used by Apache POI). </span><br /><span class="" style="white-space:pre-wrap;" /></p><ol>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="white-space:pre-wrap;">Parts are generally subclasses of </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #000000;">org</span><span class="DefaultParagraphFont " style="font-weight: bold;">.docx4j.</span><span class="DefaultParagraphFont " style="font-weight: bold;color: #000000;">openpackaging</span><span class="DefaultParagraphFont " style="font-weight: bold;">.parts.JaxbXmlPart</span><br /><br /><span style="white-space:pre-wrap;">This (the </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #000000;">jaxb</span><span class="DefaultParagraphFont " style="font-weight: bold;"><span class="" style="white-space:pre-wrap;"> content tree</span></span><span style="">) is the second level of the three layered model.</span><span style="white-space:pre-wrap;">   </span><span style="white-space:pre-wrap;">To explore these first two layers for a given document, </span><a href="http://webapp.docx4java.org/OnlineDemo/PartsList.html"><span class="Hyperlink DefaultParagraphFont " style="white-space:pre-wrap;">upload it to the </span><span class="Hyperlink DefaultParagraphFont " style="">PartsList</span><span class="Hyperlink DefaultParagraphFont " style="white-space:pre-wrap;"> </span><span class="Hyperlink DefaultParagraphFont " style="">webapp</span></a><span style="">.</span><br /><br /><span style="white-space:pre-wrap;">Parts are arranged in a tree.  If a part has descendants, it will have a </span><span class="DefaultParagraphFont " style="font-weight: bold;">org.docx4j.openpackaging.parts.relationships.RelationshipsPart</span><span style="white-space:pre-wrap;"> </span><span style="white-space:pre-wrap;">which identifies those descendant parts.  </span><br /><br /><span style="white-space:pre-wrap;">A </span><span style="">JaxbXmlPart</span><span style="white-space:pre-wrap;"> </span><span style="white-space:pre-wrap;">has a content tree:</span><br /><br /><span class="DefaultParagraphFont " style="font-size: 9.0pt;">   <span class="" style="white-space:pre-wrap;">public Object </span></span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">getJaxbElement</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">() {</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;"><br /></span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">   </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">   <span class="" style="white-space:pre-wrap;">return </span></span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">jaxbElement</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">;</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;"><br /></span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">   <span class="" style="">}</span></span><span class="DefaultParagraphFont " style="font-size: 9.0pt;"><br /></span><span class="DefaultParagraphFont " style="font-size: 9.0pt;"><br /></span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">   <span class="" style="white-space:pre-wrap;">public void </span></span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">setJaxbElement</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">(Object </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">jaxbElement</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">) {</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;"><br /></span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">   </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">   </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">this.jaxbElement</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;"><span class="" style="white-space:pre-wrap;"> = </span></span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">jaxbElement</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">;</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;"><br /></span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">   <span class="" style="">}</span></span><span class="DefaultParagraphFont " style="font-size: 9.0pt;"><br /></span></li></ol>
  
  <p class="ListParagraph Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Most parts (including </span><span class="" style="">MainDocumentPart</span><span class="" style="white-space:pre-wrap;">, styles, headers/footers, comments, </span><span class="DefaultParagraphFont " style="color: #000000;">endnotes</span><span class="" style="white-space:pre-wrap;">/footnotes) use </span><a href="http://dev.plutext.org/trac/docx4j/trac/docx4j/browser/trunk/docx4j/src/main/java/org/docx4j/wml"><span class="DefaultParagraphFont " style="font-weight: bold;">org.docx4j.wml</span></a><span class="" style="white-space:pre-wrap;" /><span class="DefaultParagraphFont " style="font-weight: bold;;white-space:pre-wrap;"> </span><span class="" style="">(WordprocessingML</span><span class="" style="white-space:pre-wrap;">); </span><span class="DefaultParagraphFont " style="color: #000000;">wml</span><span class="" style="white-space:pre-wrap;"> references </span><a href="http://dev.plutext.org/trac/docx4j/trac/docx4j/browser/trunk/docx4j/src/main/java/org/docx4j/wml"><span class="DefaultParagraphFont " style="font-weight: bold;">org.docx4j.dml</span></a><span class="" style="white-space:pre-wrap;" /><span class="DefaultParagraphFont " style="font-weight: bold;;white-space:pre-wrap;"> </span><span class="" style="">(DrawingML) as necessary.</span><br /><span class="" style="" /><br /><span class="" style="">These classes were generated from the Open XML schemas</span><br /><span class="" style="" /></p><ol>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span class="DefaultParagraphFont " style="font-weight: bold;">org.docx4j.model</span><span class="DefaultParagraphFont " style="font-weight: bold;"><br /></span><span class="DefaultParagraphFont " style="font-weight: bold;"><br /></span><span style="white-space:pre-wrap;">This package builds on the lower two layers to provide extra functionality, and is being progressively further developed.    </span></li></ol>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637350" /><span class="DefaultParagraphFont " style="">Jaxb</span><span class="DefaultParagraphFont " style="">: marshalling and unmarshalling</span><span class="DefaultParagraphFont " style="white-space:pre-wrap;"> </span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Docx4j contains a class representing each part.  For example, there is a </span><span class="DefaultParagraphFont " style="">MainDocumentPart</span><span class="" style="white-space:pre-wrap;"> class.  XML parts inherit from </span><span class="DefaultParagraphFont " style="">JaxbXmlPart</span><span class="" style="white-space:pre-wrap;">, which contains a member called </span><span class="DefaultParagraphFont " style="font-weight: bold;">jaxbElement</span><span class="" style="white-space:pre-wrap;">.  When you want to work with the contents of a part, you work with its </span><span class="" style="">jaxbElement</span><span class="" style="white-space:pre-wrap;"> by using the </span><span class="DefaultParagraphFont " style="font-weight: bold;">get|setContents</span><span class="" style="white-space:pre-wrap;"> method</span><span class="" style="">.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">When you open a docx document using docx4j, docx4j automatically </span><span class="DefaultParagraphFont " style="font-weight: bold;font-style: italic;">unmarshals</span><span class="" style="white-space:pre-wrap;"> the contents of each XML part to a strongly-type Java object tree (the </span><span class="" style="">jaxbElement).</span><span class="" style="white-space:pre-wrap;">  Actually, docx4j 3.0 is lazy;  it only does this when first needed.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Similarly, if/when you tell docx4j to save these Java objects as a docx, docx4j automatically </span><span class="DefaultParagraphFont " style="font-weight: bold;font-style: italic;">marshals</span><span class="" style="white-space:pre-wrap;"> the </span><span class="" style="">jaxbElement</span><span class="" style="white-space:pre-wrap;"> in each Part.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Sometimes you will want to marshal or </span><span class="" style="">unmarshal</span><span class="" style="white-space:pre-wrap;"> things yourself.  The class </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #000000;font-size: 9.0pt;">org.docx4j.jaxb.Context</span><span class="" style="white-space:pre-wrap;"> defines all the </span><span class="" style="">JAXBContexts</span><span class="" style="white-space:pre-wrap;"> used in docx4j.  Here is representative (non-exhaustive) content:</span></p>
  
  <table class="TableGrid TableNormal " id="docx4j_tbl_1" style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;position: relative; margin-left: 0.76in;table-layout: fixed;vertical-align: top;border-collapse: collapse;width: 4.94in;"><colgroup><col style="width: 40.51%;" /><col style="width: 59.49%;" /></colgroup><tbody><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;vertical-align: middle;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="font-size: 9.0pt;">Jc</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 9.0pt;">org.docx4j.wml<br /><span class="" style="">org.docx4j.dml</span><br /><span class="" style="">org.docx4j.dml.picture</span><br /><span class="" style="">org.docx4j.dml.wordprocessingDrawing</span><br /><span class="" style="">org.docx4j.vml</span><br /><span class="" style="">org.docx4j.vml.officedrawing</span><br /><span class="" style="">org.docx4j.math</span></span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;vertical-align: middle;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">jcThemePart</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 9.0pt;">org.docx4j.dml</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;vertical-align: middle;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">jcDocPropsCore</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 9.0pt;">org.docx4j.docProps.core</span></p>
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 9.0pt;">org.docx4j.docProps.core.dc.elements</span></p>
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 9.0pt;">org.docx4j.docProps.core.dc.terms</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;vertical-align: middle;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">jcDocPropsCustom</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 9.0pt;">org.docx4j.docProps.custom</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;vertical-align: middle;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">jcDocPropsExtended</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 9.0pt;">org.docx4j.docProps.extended</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;vertical-align: middle;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">jcXmlPackage</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 9.0pt;">org.docx4j.xmlPackage</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;vertical-align: middle;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">jcRelationships</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 9.0pt;">org.docx4j.relationships</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;vertical-align: middle;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">jcCustomXmlProperties</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 9.0pt;">org.docx4j.customXmlProperties</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;vertical-align: middle;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">jcContentTypes</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 9.0pt;">org.docx4j.openpackaging.contenttype</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;vertical-align: middle;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">jcPML</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 9.0pt;">org.docx4j.pml<br /><span class="" style="">org.docx4j.dml</span><br /><span class="" style="">org.docx4j.dml.picture</span></span></p></td></tr></tbody></table>
  
  <p class="Normal DocDefaults "> </p>
  
  <p class="Normal DocDefaults " style="border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-color: #FFFF00; border-style:solid; border-width:1px;background-color: #FFFF00;"><span class="DefaultParagraphFont " style=""><span class="" style="">You’ll find XmlUtils.marshalToString very useful as you put your code together.  With this, you can easily output the content of a JAXB object, to see what XML it represents.</span></span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637351" /><span class="DefaultParagraphFont " style="">Parts List</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">To get a better understanding of how docx4j works </span><span class="" style="">– </span><span class="" style="white-space:pre-wrap;">and the structure of a docx document </span><span class="" style="">– </span><span class="" style="white-space:pre-wrap;">you can run the </span><span class="" style="">PartsList</span><span class="" style="white-space:pre-wrap;"> sample on a docx (or a pptx or xlsx).  If you do, it will list the hierarchy of parts used in that package.  It will tell you which class is used to represent each part, and where that part is a </span><span class="" style="">JaxbXmlPart</span><span class="" style="white-space:pre-wrap;">, it will also tell you what class the </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">jaxbElement</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;"> </span><span class="" style="">is.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">So it’s a bit like unzipping the docx/pptx/xlsx file, but it tells you what Java objects are being used for each part.</span></p>
  
  <table class="TableGrid TableNormal " id="docx4j_tbl_2" style="background-color: #FFFF00;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;position: relative; margin-left: 0in;table-layout: fixed;vertical-align: top;border-collapse: collapse;width: 6.65in;"><colgroup><col style="width: 100%;" /></colgroup><tbody><tr><td style="background-color: #FFFF00;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="white-space:pre-wrap;">A more fully featured tool is </span><a href="http://webapp.docx4java.org/OnlineDemo/PartsList.html"><span class="Hyperlink DefaultParagraphFont " style="white-space:pre-wrap;">the </span><span class="Hyperlink DefaultParagraphFont " style="">PartsList</span><span class="Hyperlink DefaultParagraphFont "><span class="" style="white-space:pre-wrap;"> online </span></span><span class="Hyperlink DefaultParagraphFont " style="">webapp</span></a><span class="" style="white-space:pre-wrap;" /><span class="" style="">.  With this, you can:</span></p><ul>
  
  <li class="ListParagraph-TableGrid-BR DocDefaults " style="display: list-item;"><span style="white-space:pre-wrap;">browse through the package, </span></li>
  
  <li class="ListParagraph-TableGrid-BR DocDefaults " style="display: list-item;"><span style="white-space:pre-wrap;">look up what elements mean in the spec, and </span></li>
  
  <li class="ListParagraph-TableGrid-BR DocDefaults " style="display: list-item;"><span style="">generate code.</span></li></ul>
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="white-space:pre-wrap;">Alternatively, you can install the </span><a href="http://www.plutext.com/dn/downloads/1441189231363/Docx4jHelper-1_0.exe"><span class="Hyperlink DefaultParagraphFont " style="">Docx4j Helper Word AddIn</span></a><span class="DefaultParagraphFont " style="white-space:pre-wrap;">, to generate code from within Word.  See also forum </span><a href="http://www.docx4java.org/forums/docx4jhelper-addin-f30/"><span class="Hyperlink DefaultParagraphFont " style="">http://www.docx4java.org/forums/docx4jhelper-addin-f30/</span></a><span class="DefaultParagraphFont " style="white-space:pre-wrap;" /></p></td></tr></tbody></table>
  
  <p class="Normal DocDefaults "> </p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">You can run </span><span class="" style="">PartsList</span><span class="" style="white-space:pre-wrap;"> locally from a command line:</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 1in;text-indent: -0.5in;"><span class="apple-style-span DefaultParagraphFont " style="color: #000000;font-size: 6.5pt;">java -cp docx4j-3.0.1.jar:log4j-1.2.17.jar;</span><span class="DefaultParagraphFont " style="color: #222222;background-color: #FFFFFF;font-size: 6.5pt;">slf4j-api-1.7.5.jar;slf4j-log4j12-1.7.5.jar</span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;font-size: 6.5pt;;white-space:pre-wrap;"> </span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;font-size: 6.5pt;"><br /><span class="" style="">org.docx4j.samples.</span></span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;font-size: 6.5pt;;white-space:pre-wrap;"> </span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;font-size: 6.5pt;">PartsList<span class="" style="white-space:pre-wrap;"> [input.docx]</span></span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">though I always find it easier to run it from my IDE.   Example</span><span class="" style="white-space:pre-wrap;"> output: </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">Part /_rels/.rels<span class="" style="white-space:pre-wrap;"> [org.docx4j.openpackaging.parts.relationships.RelationshipsPart]</span><br /><span class="" style="white-space:pre-wrap;">  containing JaxbElement:org.docx4j.relationships.Relationships</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">Part /docProps</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">/app.xml [org.docx4j.openpackaging.parts.DocPropsExtendedPart]  </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;"><br /><span class="" style="white-space:pre-wrap;">  containing JaxbElement:org.docx4j.docProps.extended.Properties</span></span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">Part /docProps</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">/core.xml [org.docx4j.openpackaging.parts.DocPropsCorePart]  </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;"><br /><span class="" style="white-space:pre-wrap;">  containing JaxbElement:org.docx4j.docProps.core.CoreProperties</span></span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">Part </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #000000;font-size: 8.0pt;">/word/document.xml</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> [org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart]  </span><br /><span class="" style="white-space:pre-wrap;">  containing JaxbElement:org.docx4j.wml.Document</span></span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 1in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">Part /word/settings.xml [</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 7.0pt;">org.docx4j.openpackaging.parts.WordprocessingML</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">.DocumentSettingsPart]  </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;"><br /><span class="" style="white-space:pre-wrap;">  containing JaxbElement:org.docx4j.wml.CTSettings</span></span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 1in;margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 1in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">Part /word/styles.xml [</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 7.0pt;">org.docx4j.openpackaging.parts.WordprocessingML</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">.StyleDefinitionsPart]  </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;"><br /><span class="" style="white-space:pre-wrap;">  containing JaxbElement:org.docx4j.wml.Styles</span></span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 1in;margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 1in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">Part /word/media/image1.jpeg [</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 7.0pt;">org.docx4j.openpackaging.parts.WordprocessingML</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">.ImageJpegPart] </span></p>
  
  <p class="Normal DocDefaults "> </p>
  
  <p class="Normal DocDefaults "><span class="" style="">docx4j includes convenience methods to make it easy to access commonly used parts. These include,</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">on the package:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">MainDocumentPart</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">getMainDocumentPart</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">() </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">DocPropsCorePart</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">getDocPropsCorePart</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">() </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">DocPropsExtendedPart</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">getDocPropsExtendedPart</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">() </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">DocPropsCustomPart</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">getDocPropsCustomPart</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">() </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults "><span class="" style="">on the document part:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">StyleDefinitionsPart</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">getStyleDefinitionsPart()</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">NumberingDefinitionsPart</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">getNumberingDefinitionsPart()</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">ThemePart</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">getThemePart()</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">FontTablePart</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">getFontTablePart()</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">CommentsPart</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">getCommentsPart()</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">EndnotesPart</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">getEndNotesPart()</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">FootnotesPart</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">getFootnotesPart()</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">DocumentSettingsPart</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">getDocumentSettingsPart()</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">WebSettingsPart</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">getWebSettingsPart()</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">If a part points to any other parts, it will have a relationships part listing these other parts. </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   RelationshipsPart</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">rp<span class="" style="white-space:pre-wrap;"> = </span>part.getRelationshipsPart();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults "><span class="" style="">You can access those, and from there, get the part you want:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">for</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> ( Relationship r : </span>rp.getRelationships().getRelationship() ) {</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">         </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">      </span><span class="DefaultParagraphFont " style="color: #0000C0;font-style: italic;font-size: 8.0pt;">log</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">.info(</span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 8.0pt;">"\nFor<span class="" style="white-space:pre-wrap;"> Relationship Id="</span></span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> + </span>r.getId</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">() </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">            <span class="" style="white-space:pre-wrap;">+ </span></span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 8.0pt;">" Source is "</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> + </span>rp.getSourceP().getPartName</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">() </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">            <span class="" style="white-space:pre-wrap;">+ </span></span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 8.0pt;">", Target is "</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> + </span>r.getTarget</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">() </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">            <span class="" style="white-space:pre-wrap;">+ </span></span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 8.0pt;">" type "</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> + </span>r.getType</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">() + </span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 8.0pt;">"\n"</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">);</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">      </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">      <span class="" style="white-space:pre-wrap;">Part </span>part<span class="" style="white-space:pre-wrap;"> = </span>rp.getPart(r);</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   <span class="" style="">}</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">         </span></p>
  
  <p class="Normal DocDefaults "> </p>
  
  <p class="Normal DocDefaults "><span class="" style="">That gives access to just the parts this part points to.</span><span class="" style="white-space:pre-wrap;">  </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">RelationshipsPart</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="" style="">contains</span><span class="" style="white-space:pre-wrap;"> various useful utility methods, for example</span><span class="" style="">:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">   </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 10.0pt;">/** Gets a loaded Part by its id */</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">   </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 10.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> Part </span></span><span class="DefaultParagraphFont " style="color: #000000;background-color: #D3D3D3;font-size: 10.0pt;">getPart</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;">(String id) </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">   </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 10.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> Part </span>getPart(Relationship r ) {</span></p>
  
  <p class="Normal DocDefaults "> </p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">The  </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">RelationshipsPart</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;"> </span><span class="" style="">is the key player when it comes to adding/removing images and other parts from your document.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">There is also a list of </span><span class="DefaultParagraphFont " style="font-weight: bold;">all</span><span class="" style="white-space:pre-wrap;"> parts, in the package object:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   <span class="" style="white-space:pre-wrap;">Parts </span>parts<span class="" style="white-space:pre-wrap;"> = </span>wordMLPackage.getParts();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="" style="white-space:pre-wrap;">The Parts object encapsulates a map of parts, keyed by </span><span class="" style="">PartName, but you generally shouldn’t add/remove things here directly!</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">To add a part, see the section </span><a href="#_Ref275255216"><span style="">Adding a Part</span></a><span class="" style="white-space:pre-wrap;"> below.</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637352" /><span class="DefaultParagraphFont " style="">MainDocumentPart</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">The text of the document is to be found in the main document part.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Its XML will look something like:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&lt;</span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">w:document</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.5pt;">xmlns:w</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">=</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">http://schemas.openxmlformats.org/wordprocessingml/2006/main</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;"> &gt;</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;">  &lt;</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">w:body</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;">    &lt;</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">w:p</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;"> &gt;</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;">      &lt;</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">w:pPr</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;">        &lt;</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">w:pStyle</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.5pt;">w:val</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">=</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">Heading1</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">/&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;">      &lt;/</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">w:pPr</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;">      &lt;</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">w:r</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;">        &lt;</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">w:t</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&gt;</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">Hello World</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&lt;/</span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">w:t</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;">      &lt;/</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">w:r</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;">    &lt;/</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">w:p</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;">    :</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;">    &lt;</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">w:sectPr</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;"> &gt;</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;">      &lt;</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">w:pgSz</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.5pt;">w:w</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">=</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">12240</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.5pt;">w:h</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">=</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">15840</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">/&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;">      &lt;</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">w:pgMar</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.5pt;">w:top</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">=</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">1440</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.5pt;">w:right</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">=</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">1440</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.5pt;">w:bottom</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">=</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">1440</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.5pt;">w:left</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">=</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">1440</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.5pt;">w:header</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">=</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">708</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.5pt;">w:footer</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">=</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">708</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.5pt;">w:gutter</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">=</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">0</span><span class="DefaultParagraphFont " style="font-size: 9.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">/&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;">    &lt;/</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">w:sectPr</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;"><span class="" style="white-space:pre-wrap;">  &lt;/</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">w:body</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&lt;/</span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 9.5pt;">w:document</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults "> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">Given:</span></p>
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">WordprocessingMLPackage wordMLPackage</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">you can access:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">   MainDocumentPart</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">documentPart<span class="" style="white-space:pre-wrap;"> = </span>wordMLPackage.getMainDocumentPart();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">Classically, you'd then do:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">   <span class="" style="white-space:pre-wrap;">org.docx4j.wml.Document </span>wmlDocumentEl</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;"> </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">      <span class="" style="white-space:pre-wrap;">= (org.docx4j.wml.Document) </span>documentPart.getJaxbElement();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">   <span class="" style="white-space:pre-wrap;">Body </span>body<span class="" style="white-space:pre-wrap;"> = </span>wmlDocumentEl.getBody();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0.07in;line-height: 100%;"><span class="" style="white-space:pre-wrap;">But </span><span class="" style="">you can skip some of that with:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 10.0pt;">/**</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;">     * Convenience method to </span>getJaxbElement().getBody().getContent()</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;">     */</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 10.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> List&lt;Object&gt; </span>getContent</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;">() </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">A paragraph is org.docx4j.wml.P; a paragraph is basically made up of runs of text.</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #646464;font-size: 10.0pt;">@</span><span class="DefaultParagraphFont " style="color: #646464;font-size: 10.0pt;text-decoration: underline;">XmlRootElement</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;">(name = </span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 10.0pt;">"p"</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">)</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 10.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 10.0pt;">class</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> P </span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 10.0pt;">implements</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> Child, </span>ContentAccessor</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0.07in;line-height: 100%;"><span class="" style="white-space:pre-wrap;">The </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">ContentAccessor</span><span class="" style="white-space:pre-wrap;"> interface is simply:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 10.0pt;">/**</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> * </span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F9FBF;font-size: 10.0pt;">@since</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> 2.7</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> */</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 10.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 10.0pt;">interface</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;background-color: #D3D3D3;font-size: 10.0pt;">ContentAccessor</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> {</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 10.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> List&lt;Object&gt; </span>getContent();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">   </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">}</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">it is implemented by a number of objects, including:</span></p>
  
  <table class="TableGrid TableNormal " id="docx4j_tbl_3" style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;position: relative; margin-left: 0.86in;table-layout: fixed;vertical-align: top;border-collapse: collapse;width: 132mm;"><colgroup><col style="width: 33.97%;" /><col style="width: 24.53%;" /><col style="width: 41.5%;" /></colgroup><tbody><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">Body</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">w:body</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">document body</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">P</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">w:p</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">paragraph</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">R</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">w:r</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">run</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">Tbl</span></p>
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">Tr</span></p>
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">Tc</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">w:tbl</span></p>
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">w:tr</span></p>
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">w:tc</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">table</span></p>
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">table row</span></p>
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">table cell</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">SdtBlock</span></p>
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">SdtRun</span></p>
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">CTSdtRow</span></p>
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">CTSdtCell</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">w:sdt</span></p>
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">w:sdt</span></p>
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">w:sdt</span></p>
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">w:sdt</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">content controls; see the method</span><span class="DefaultParagraphFont " style="color: #000000;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;">getSdtContent()</span></p></td></tr></tbody></table>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0.07in;line-height: 100%;"><span class="" style="white-space:pre-wrap;">As well as </span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-bottom: 0.07in;line-height: 100%;"><span style="">Hdr</span><span style="white-space:pre-wrap;">, </span><span style="">Ftr</span></li></ul>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.25in;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-color: #FFFF00; border-style:solid; border-width:1px;background-color: #FFFF00;"><span class="" style="">Content is generally stored in a plain old Java List.  So there are familiar methods for inserting content at the end of the list, or other location in it.</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">Read on for how to add text etc.</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637353" /><span class="DefaultParagraphFont " style="">Samples</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="white-space:pre-wrap;">The </span><span class="" style="">modules:</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span style="">docx4j-samples-docx4j</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span style="">docx4j-samples-docx-diffx</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span style="">docx4j-samples-docx-export-fo</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span style="">docx4j-samples-pptx4j</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span style="">docx4j-samples-xlsx4j</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span style="">docx4j-samples-glox4</span></li></ul>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="white-space:pre-wrap;">contains examples of how to do things with docx4j. </span><span class="" style="">You can find them in the GitHub repo.</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">The docx4j samples include:</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.25in;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">Basics</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">CreateWordprocessingMLDocument</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">DisplayMainDocumentPartXml</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">OpenAndSaveRoundTripTest</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">PartsList</span></li></ul>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.25in;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">Navigating the document body</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">OpenMainDocumentAndTraverse</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">XPathQuery</span></li></ul>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.25in;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">Output/Transformation</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">ConvertOutHtml</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">ConvertOutPDF</span></li></ul>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.25in;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">Import (X)HTML</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">AltChunkXHTMLRoundTrip</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">AltChunkAddOfTypeHtml</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">ConvertIn</span><span class="DefaultParagraphFont " style="font-size: 10.0pt;">XHTMLDocument</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">ConvertInXHTML</span><span class="DefaultParagraphFont " style="font-size: 10.0pt;">Fragment</span></li></ul>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.25in;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;;white-space:pre-wrap;">Image handling </span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">Image</span><span class="DefaultParagraphFont " style="font-size: 10.0pt;">Add</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">Image</span><span class="DefaultParagraphFont " style="font-size: 10.0pt;">ConvertEmbedded</span><span class="DefaultParagraphFont " style="font-size: 10.0pt;">ToLinked</span></li></ul>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.25in;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">Part Handling</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">PartCopy</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">PartLoadFromFileSystem</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">PartsList</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">PartsStrip</span></li></ul>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.25in;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">Document generation/document assembly using content controls</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">ContentControlsAddCustomXmlDataStoragePart</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">ContentControlsXmlEdit</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">ContentControlsApplyBinding</span><span class="DefaultParagraphFont " style="font-size: 10.0pt;">s</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">ContentControlBindingExtensions</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">ContentControlsPartsInfo</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">AltChunkAddOfTypeDocx</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">VariableReplace</span><span class="DefaultParagraphFont " style="font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> (not recommended)</span></span></li></ul>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.25in;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.25in;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">Specific docx features</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">BookmarkAdd</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">CommentsSample</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">HeaderFooterCreate</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">HeaderFooterList</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">HyperlinkTest</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">NumberingRestart</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">SubDocument</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">TableOfContentsAdd</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">TemplateAttach</span><span class="DefaultParagraphFont " style="font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> (attach your.dotx)</span></span></li></ul>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.25in;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">Miscellaneous</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">CompareDocuments</span><span class="DefaultParagraphFont " style="font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> (in </span></span><span style="">docx4j-samples-docx-diffx</span><span style="">)</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">DocProps</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">Filter</span><span class="DefaultParagraphFont " style="font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> (remove proof errors, w:rsid)</span></span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">MergeDocx</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">UnmarshallFromTemplate</span></li></ul>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.25in;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;;white-space:pre-wrap;">Flat OPC XML </span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">ConvertOutFlatOpenPackage</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 10.0pt;">ConvertInFlatOpenPackage</span></li></ul>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"> </p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637354" /><span class="DefaultParagraphFont " style="">Creating a new docx</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">To create a new docx:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 9.0pt;">// Create the package</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 9.0pt;">// Save it</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">wordMLPackage.save</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">(new </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">java.io.File("helloworld.docx") );</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="white-space:pre-wrap;">That's it.  </span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">There’s a sample you can try locally from a command line:</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 1in;text-indent: -0.5in;"><span class="apple-style-span DefaultParagraphFont " style="color: #000000;font-size: 6.5pt;">java -cp docx4j-3.0.1.jar:log4j-1.2.17.jar;</span><span class="DefaultParagraphFont " style="color: #222222;background-color: #FFFFFF;font-size: 6.5pt;">slf4j-api-1.7.5.jar;slf4j-log4j12-1.7.5.jar</span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;font-size: 6.5pt;;white-space:pre-wrap;"> </span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;font-size: 6.5pt;"><br /><span class="" style="">org.docx4j.samples.</span></span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;font-size: 6.5pt;;white-space:pre-wrap;"> </span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;font-size: 6.5pt;">CreateDocx<span class="" style="white-space:pre-wrap;"> [input.docx]</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;">createPackage() </span><span class="" style="">is a convenience method, which does:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 9.0pt;">// Create the package</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">WordprocessingMLPackage wordMLPackage = new WordprocessingMLPackage();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 9.0pt;">// Create the main document part (word/document.xml)</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">MainDocumentPart</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">wordDocumentPart<span class="" style="white-space:pre-wrap;"> = new </span>MainDocumentPart();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 9.0pt;">// Create main document part content</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">ObjectFactory factory = Context.getWmlObjectFactory();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">org.docx4j.wml.Body body = factory .createBody();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">org.docx4j.wml.Document wmlDocumentEl = factory .createDocument();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">wmlDocumentEl.setBody(body);</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 9.0pt;">// Put the content in the part</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">wordDocumentPart.setJaxbElement(wmlDocumentEl);</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">            </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 9.0pt;">// Add the main document part to the package relationships</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 9.0pt;">// (creating it if necessary)</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">wmlPack.addTargetPart(wordDocumentPart);</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637355" /><a name="_Ref273525601" /><span style="">docx4j.properties</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Here is a sample short </span><span class="" style="">docx4j.properties file</span><span class="" style="white-space:pre-wrap;"> (a complete one may be copied from </span><span class="" style="">docx4j-samples-resources module):</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;"># Page size: use a value from org.docx4j.model.structure.PageSizePaper </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">enum</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;"># </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">eg<span class="" style="white-space:pre-wrap;"> A4, LETTER</span></span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">docx4j.PageSize=</span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 8.0pt;">LETTER</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;"># Page size: use a value from org.docx4j.model.structure.MarginsWellKnown </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">enum</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">docx4j.PageMargins=</span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 8.0pt;">NORMAL</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">docx4j.PageOrientationLandscape=</span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 8.0pt;">false</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;"># Page size: use a value from org.pptx4j.model.SlideSizesWellKnown </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">enum</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;"># </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">eg<span class="" style="white-space:pre-wrap;"> A4, LETTER</span></span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">pptx4j.PageSize=</span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 8.0pt;">LETTER</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">pptx4j.PageOrientationLandscape=</span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 8.0pt;">false</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;"># These will be injected into </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">docProps/app.xml</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;"># if </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">App.Write=true</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">docx4j.App.write=</span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 8.0pt;">true</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">docx4j.Application=</span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 8.0pt;">docx4j</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">docx4j.AppVersion=</span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 8.0pt;">2.7</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;"># of the form XX.YYYY where X and Y represent numerical values</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;"># These will be injected into </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">docProps/core.xml</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">docx4j.dc.write=</span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 8.0pt;">true</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">docx4j.dc.creator.value=</span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 8.0pt;">docx4j</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">docx4j.dc.lastModifiedBy.value=</span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 8.0pt;">docx4j</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">#</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">#docx4j.McPreprocessor=true</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;"># If you haven't configured log4j yourself</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;"># docx4j will autoconfigure it.  Set this to true to disable that</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">docx4j.Log4j.Configurator.disabled=</span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 8.0pt;">false</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">The page size, margin &amp; orientation values are used when new documents are created; naturally they don't affect an existing document you open with docx4j.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">If no docx4j.properties file is found on your class path, docx4j has hard coded defaults.</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637356" /><span style="">Adding a paragraph of text</span></p>
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="font-size: 9.0pt;">MainDocumentPart</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;"> </span><span class="" style="">contains a method:</span></p>
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">  </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 9.0pt;;white-space:pre-wrap;">public </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">org.docx4j.wml.P addStyledParagraphOfText(String styleId, String text)</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">You can use that method to add a paragraph using the specified style.</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">The XML we are looking to create will be something like:</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="xmlmarkupbracket DefaultParagraphFont " style="color: #0000FF;font-size: 8.5pt;">&lt;</span><span class="xmlmarkuptagname DefaultParagraphFont " style="color: #A31515;font-size: 8.5pt;">w:p</span><span class="xmlmarkuptagname DefaultParagraphFont " style="color: #A31515;font-size: 8.5pt;;white-space:pre-wrap;"> </span><span class="apple-converted-space DefaultParagraphFont " style="color: #000000;font-size: 8.5pt;"> </span><span class="xmlmarkupattributename DefaultParagraphFont " style="color: #FF0000;font-size: 8.5pt;">xmlns:w</span><span class="xmlmarkupattributevalue DefaultParagraphFont " style="color: #0000FF;font-size: 8.5pt;">="http://schemas.openxmlformats.org/wordprocessingml/2006/main"</span><span class="xmlmarkupbracket DefaultParagraphFont " style="color: #0000FF;font-size: 8.5pt;">&gt;</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.5pt;"><br /></span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;font-size: 8.5pt;"><span class="" style="">    </span></span><span class="xmlmarkupbracket DefaultParagraphFont " style="color: #0000FF;font-size: 8.5pt;">&lt;</span><span class="xmlmarkuptagname DefaultParagraphFont " style="color: #A31515;font-size: 8.5pt;">w:r</span><span class="xmlmarkupbracket DefaultParagraphFont " style="color: #0000FF;font-size: 8.5pt;">&gt;</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.5pt;"><br /></span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;font-size: 8.5pt;"><span class="" style="">        </span></span><span class="xmlmarkupbracket DefaultParagraphFont " style="color: #0000FF;font-size: 8.5pt;">&lt;</span><span class="xmlmarkuptagname DefaultParagraphFont " style="color: #A31515;font-size: 8.5pt;">w:t</span><span class="xmlmarkupbracket DefaultParagraphFont " style="color: #0000FF;font-size: 8.5pt;">&gt;</span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;font-size: 8.5pt;">Hello world</span><span class="xmlmarkupbracket DefaultParagraphFont " style="color: #0000FF;font-size: 8.5pt;">&lt;/</span><span class="xmlmarkuptagname DefaultParagraphFont " style="color: #A31515;font-size: 8.5pt;">w:t</span><span class="xmlmarkupbracket DefaultParagraphFont " style="color: #0000FF;font-size: 8.5pt;">&gt;</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.5pt;"><br /></span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;font-size: 8.5pt;"><span class="" style="">    </span></span><span class="xmlmarkupbracket DefaultParagraphFont " style="color: #0000FF;font-size: 8.5pt;">&lt;/</span><span class="xmlmarkuptagname DefaultParagraphFont " style="color: #A31515;font-size: 8.5pt;">w:r</span><span class="xmlmarkupbracket DefaultParagraphFont " style="color: #0000FF;font-size: 8.5pt;">&gt;</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.5pt;"><br /></span><span class="xmlmarkupbracket DefaultParagraphFont " style="color: #0000FF;font-size: 8.5pt;">&lt;/</span><span class="xmlmarkuptagname DefaultParagraphFont " style="color: #A31515;font-size: 8.5pt;">w:p</span><span class="xmlmarkupbracket DefaultParagraphFont " style="color: #0000FF;font-size: 8.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;">addStyledParagraphOfText </span><span class="" style="">builds the object structure “the JAXB way”, and adds it to the document.</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">It is based on:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">   </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 10.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> org.docx4j.wml.P </span>createParagraphOfText</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;">(String </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">simpleText) {</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">      </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">      <span class="" style="white-space:pre-wrap;">org.docx4j.wml.ObjectFactory factory = </span>Context.</span><span class="DefaultParagraphFont " style="color: #000000;font-style: italic;font-size: 10.0pt;">getWmlObjectFactory</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">      <span class="" style="white-space:pre-wrap;">org.docx4j.wml.P  para = </span>factory.createP();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">      </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 10.0pt;">if</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> (</span>simpleText!=</span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 10.0pt;">null</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">) {</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">         <span class="" style="white-space:pre-wrap;">org.docx4j.wml.Text  t = </span>factory.createText();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">         t.setValue(simpleText);</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">   </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">         <span class="" style="white-space:pre-wrap;">org.docx4j.wml.R  run = </span>factory.createR();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">         run.</span><span class="DefaultParagraphFont " style="font-weight: bold;color: #000000;font-size: 10.0pt;">getContent</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;">().add(t); </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 10.0pt;;white-space:pre-wrap;">// </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 10.0pt;">ContentAccessor      </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">         </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">         para.</span><span class="DefaultParagraphFont " style="font-weight: bold;color: #000000;font-size: 10.0pt;">getContent</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;">().add(run); </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 10.0pt;;white-space:pre-wrap;">// </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 10.0pt;">ContentAccessor</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">      <span class="" style="">}</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">      </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">      </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 10.0pt;">return</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> para;</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">   <span class="" style="">}</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 4mm;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="white-space:pre-wrap;">Notice that the paragraph, the run, and indeed the Body, all implement the </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">ContentAccessor</span><span class="" style="white-space:pre-wrap;"> interface:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 10.0pt;">/**</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> * </span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F9FBF;font-size: 10.0pt;">@since</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> 2.7</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> */</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 10.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 10.0pt;">interface</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;background-color: #D3D3D3;font-size: 10.0pt;">ContentAccessor</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> {</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 10.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> List&lt;Object&gt; </span>getContent();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">   </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">}</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="white-space:pre-wrap;">The add method adds the content at the end of the document.  If you want to insert it somewhere else, </span><span class="" style="">you could use something like:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> org.docx4j.wml.P </span>addParaAtIndex(MainDocumentPart</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">mdp,</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">         <span class="" style="white-space:pre-wrap;">String </span>simpleText</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">, </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">int</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> index) {</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">      <span class="" style="white-space:pre-wrap;">org.docx4j.wml.ObjectFactory factory = </span>Context.</span><span class="DefaultParagraphFont " style="color: #000000;font-style: italic;font-size: 8.0pt;">getWmlObjectFactory</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">      <span class="" style="white-space:pre-wrap;">org.docx4j.wml.P para = </span>factory.createP();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">      </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">if</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> (</span>simpleText<span class="" style="white-space:pre-wrap;"> != </span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">null</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">) {</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">         <span class="" style="white-space:pre-wrap;">org.docx4j.wml.Text t = </span>factory.createText();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">         t.setValue(simpleText);</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">         <span class="" style="white-space:pre-wrap;">org.docx4j.wml.R run = </span>factory.createR();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">         run.getContent().add(t);</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">         para.getContent().add(run);</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">      <span class="" style="">}</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">      mdp.getContent().add(index, para);</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">      </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">return</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> para;</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   <span class="" style="">}</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">Alternatively, you can create the paragraph by marshalling XML:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 9.0pt;">// Assuming String xml contains the XML above</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">org.docx4j.wml.P  para = XmlUtils.unmarshalString(xml);</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">For this to work, you need to ensure that all namespaces are declared properly in the string.</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">See further below for adding images, and tables.</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Ref273526076" /><a name="_Toc532637357" /><span class="DefaultParagraphFont " style="">General strategy/approach for creating stuff</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">The first thing you need to know is what the XML you are trying to create looks like.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">To figure this out, start with a docx that contains the construct (create it in Word if necessary).</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Now look at its XML. Choices:</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="white-space:pre-wrap;">You can unzip it to do this </span><span style="white-space:pre-wrap;"> </span><span style="">blagh</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="white-space:pre-wrap;">upload it to </span><a href="http://webapp.docx4java.org/OnlineDemo/PartsList.html"><span class="Hyperlink DefaultParagraphFont " style="white-space:pre-wrap;">the </span><span class="Hyperlink DefaultParagraphFont " style="">PartsList</span><span class="Hyperlink DefaultParagraphFont " style="white-space:pre-wrap;"> </span><span class="Hyperlink DefaultParagraphFont " style="white-space:pre-wrap;">online </span><span class="Hyperlink DefaultParagraphFont " style="">webapp</span></a><span style="white-space:pre-wrap;"> </span><span style="white-space:pre-wrap;">(which can also generate code for you)</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="white-space:pre-wrap;">save it as Flat OPC XML from Word (or use the </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">ExportInPackageFormat</span><span style="white-space:pre-wrap;"> </span><span style="white-space:pre-wrap;">sample),  so you have just a single XML file which you don't need to unzip</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="white-space:pre-wrap;">you can use the </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">DisplayMainDocumentPartXml</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;">to get it</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span class="DefaultParagraphFont " style="color: #000000;">you can open it with docx4all, and look at the source view</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span class="DefaultParagraphFont " style="color: #000000;">on Windows, if you have Visual Studio 2010, you can drag the docx onto it</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span class="DefaultParagraphFont " style="color: #000000;"><span class="" style="white-space:pre-wrap;">if you use Google</span><span class="" style="">’</span><span class="" style="white-space:pre-wrap;">s Chrome web browser, try </span></span><a href="https://chrome.google.com/webstore/detail/ooxml-viewer/bjmmjfdegplhkefakjkccocjanekbapn"><span class="Hyperlink DefaultParagraphFont " style="font-weight: bold;color: #0066DD;background-color: #F7F7F7;font-size: 9.0pt;">OOXML Viewer for Chrome</span></a><span class="DefaultParagraphFont " style="color: #000000;">.</span></li></ul>
  
  <p class="Normal DocDefaults "><span class="" style="">Now you are ready to create this XML using JAXB.  There are 2 basic ways.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">The classic JAXB way is to use the </span><span class="" style="">ObjectFactory's</span><span class="" style="white-space:pre-wrap;"> .</span><span class="" style="">createX</span><span class="" style="white-space:pre-wrap;"> methods.  For example:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;">       </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">ObjectFactory<span class="" style="white-space:pre-wrap;"> factory = </span>Context.</span><span class="DefaultParagraphFont " style="color: #000000;font-style: italic;font-size: 9.0pt;">getWmlObjectFactory</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;">(); </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;"><span class="" style="white-space:pre-wrap;">       P </span>p<span class="" style="white-space:pre-wrap;"> = </span>factory.createP();   </span></p>
  
  <p class="Normal DocDefaults "> </p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">The challenge with this is to know what object it is you are trying to create.  To find this out, the easiest way by far is to use </span><a href="http://webapp.docx4java.org/OnlineDemo/PartsList.html"><span class="Hyperlink DefaultParagraphFont " style="white-space:pre-wrap;">the </span><span class="Hyperlink DefaultParagraphFont " style="">PartsList</span><span class="Hyperlink DefaultParagraphFont " style="white-space:pre-wrap;"> </span><span class="Hyperlink DefaultParagraphFont " style="white-space:pre-wrap;">online </span><span class="Hyperlink DefaultParagraphFont " style="">webapp</span></a><span class="" style="white-space:pre-wrap;">.  Alternatively, you could run </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">OpenMainDocumentAndTraverse</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;"> </span><span class="" style="">on your document, or use Eclipse to search the relevant schema (in /xsd) or source code.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Here are the names for some common objects:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <table class="TableGrid TableNormal " id="docx4j_tbl_4" style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;position: relative; margin-left: 0.37in;table-layout: fixed;vertical-align: top;border-collapse: collapse;width: 5.12in;"><colgroup><col style="width: 19.22%;" /><col style="width: 17.31%;" /><col style="width: 32.36%;" /><col style="width: 31.11%;" /></colgroup><tbody><tr><td style="background-color: #D9D9D9;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="font-weight: bold;color: #000000;font-size: 9.0pt;">Object</span></p></td><td style="background-color: #D9D9D9;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="font-weight: bold;color: #000000;font-size: 9.0pt;">XML element</span></p></td><td style="background-color: #D9D9D9;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="font-weight: bold;color: #000000;font-size: 9.0pt;">docx4j class</span></p></td><td style="background-color: #D9D9D9;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="font-weight: bold;color: #000000;font-size: 9.0pt;">Factory method</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">Document body</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">w:body</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">org.docx4j.wml.Body</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">factory.createBody();</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">Paragraph</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">w:p</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">org.docx4j.wml.P</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">factory.createP()</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">Paragraph props</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">w:pPr</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">org.docx4j.wml.PPr</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">factory.createPPr()</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">Run</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">w:r</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">org.docx4j.wml.R</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">factory.createR()</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">Run props</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">w:rPr</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">org.docx4j.wml.RPr</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">factory.createRPr()</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">Text</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">w:t</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">org.docx4j.wml.Text</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">factory.createText()</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">Table</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">w:tbl</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">org.docx4j.wml.Tbl</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">factory.createTbl()</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">Table row</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">w:tr</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">org.docx4j.wml.Tr</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">factory.createTr()</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">Table cell</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">w:tc</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">org.docx4j.wml.Tc</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">factory.createTc()</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">Drawing</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">w:drawing</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">org.docx4j.wml.Drawing</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">factory.createDrawing()</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">Page break</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">w:br</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">org.docx4j.wml.Br</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">factory.createBr()</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;">Footnote </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;"><br /><span class="" style="">or endnote ref</span></span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">?</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">org.docx4j.wml.CTFtnEdnRef</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">factory.createCTFtnEdnRef()</span></p></td></tr></tbody></table>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;"> </span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">An easier way to create stuff may be to just </span><span class="" style="">unmarshal</span><span class="" style="white-space:pre-wrap;"> the  XML (</span><span class="" style="">eg</span><span class="" style="white-space:pre-wrap;"> a String representing a paragraph to be inserted into the document).</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">For example, given:</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="xmlmarkupbracket DefaultParagraphFont " style="color: #0000FF;font-size: 8.5pt;">&lt;</span><span class="xmlmarkuptagname DefaultParagraphFont " style="color: #A31515;font-size: 8.5pt;">w:p</span><span class="xmlmarkuptagname DefaultParagraphFont " style="color: #A31515;font-size: 8.5pt;;white-space:pre-wrap;"> </span><span class="apple-converted-space DefaultParagraphFont " style="color: #000000;font-size: 8.5pt;"> </span><span class="xmlmarkupattributename DefaultParagraphFont " style="color: #FF0000;font-size: 8.5pt;">xmlns:w</span><span class="xmlmarkupattributevalue DefaultParagraphFont " style="color: #0000FF;font-size: 8.5pt;">="http://schemas.openxmlformats.org/wordprocessingml/2006/main"</span><span class="xmlmarkupbracket DefaultParagraphFont " style="color: #0000FF;font-size: 8.5pt;">&gt;</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.5pt;"><br /></span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;font-size: 8.5pt;"><span class="" style="">    </span></span><span class="xmlmarkupbracket DefaultParagraphFont " style="color: #0000FF;font-size: 8.5pt;">&lt;</span><span class="xmlmarkuptagname DefaultParagraphFont " style="color: #A31515;font-size: 8.5pt;">w:r</span><span class="xmlmarkupbracket DefaultParagraphFont " style="color: #0000FF;font-size: 8.5pt;">&gt;</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.5pt;"><br /></span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;font-size: 8.5pt;"><span class="" style="">        </span></span><span class="xmlmarkupbracket DefaultParagraphFont " style="color: #0000FF;font-size: 8.5pt;">&lt;</span><span class="xmlmarkuptagname DefaultParagraphFont " style="color: #A31515;font-size: 8.5pt;">w:t</span><span class="xmlmarkupbracket DefaultParagraphFont " style="color: #0000FF;font-size: 8.5pt;">&gt;</span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;font-size: 8.5pt;">Hello world</span><span class="xmlmarkupbracket DefaultParagraphFont " style="color: #0000FF;font-size: 8.5pt;">&lt;/</span><span class="xmlmarkuptagname DefaultParagraphFont " style="color: #A31515;font-size: 8.5pt;">w:t</span><span class="xmlmarkupbracket DefaultParagraphFont " style="color: #0000FF;font-size: 8.5pt;">&gt;</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.5pt;"><br /></span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;font-size: 8.5pt;"><span class="" style="">    </span></span><span class="xmlmarkupbracket DefaultParagraphFont " style="color: #0000FF;font-size: 8.5pt;">&lt;/</span><span class="xmlmarkuptagname DefaultParagraphFont " style="color: #A31515;font-size: 8.5pt;">w:r</span><span class="xmlmarkupbracket DefaultParagraphFont " style="color: #0000FF;font-size: 8.5pt;">&gt;</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.5pt;"><br /></span><span class="xmlmarkupbracket DefaultParagraphFont " style="color: #0000FF;font-size: 8.5pt;">&lt;/</span><span class="xmlmarkuptagname DefaultParagraphFont " style="color: #A31515;font-size: 8.5pt;">w:p</span><span class="xmlmarkupbracket DefaultParagraphFont " style="color: #0000FF;font-size: 8.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">you can simply:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 9.0pt;">// Assuming String xml contains the XML above</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">org.docx4j.wml.P  para = XmlUtils.unmarshalString(xml);</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-color: #FFFF00; border-style:solid; border-width:1px;background-color: #FFFF00;"><span class="" style="white-space:pre-wrap;">The </span><a href="http://webapp.docx4java.org/OnlineDemo/PartsList.html"><span class="Hyperlink DefaultParagraphFont " style="">PartsList</span><span class="Hyperlink DefaultParagraphFont " style="white-space:pre-wrap;"> </span><span class="Hyperlink DefaultParagraphFont " style="white-space:pre-wrap;">online </span><span class="Hyperlink DefaultParagraphFont " style="">webapp</span></a><span class="" style="white-space:pre-wrap;"> can generate appropriate code for you, using both of these approaches.  It also links to the Open XML spec documentation for the element.</span></p>
  
  <p class="Normal DocDefaults " style="border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-color: #FFFF00; border-style:solid; border-width:1px;background-color: #FFFF00;"><span class="DefaultParagraphFont " style="white-space:pre-wrap;">Alternatively, you can install the </span><a href="http://www.plutext.com/dn/downloads/1441189231363/Docx4jHelper-1_0.exe"><span class="Hyperlink DefaultParagraphFont " style="">Docx4j Helper Word AddIn</span></a><span class="DefaultParagraphFont " style="white-space:pre-wrap;">, to generate code from within Word.  See also forum </span><a href="http://www.docx4java.org/forums/docx4jhelper-addin-f30/"><span class="Hyperlink DefaultParagraphFont " style="">http://www.docx4java.org/forums/docx4jhelper-addin-f30/</span></a><span class="DefaultParagraphFont " style="white-space:pre-wrap;" /></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">If you need to be explicit about the type, you can use:</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">  </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 9.0pt;;white-space:pre-wrap;">public static </span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;">Object </span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">unmarshalString</span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;">(String str, </span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">JAXBContext</span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;"> </span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">jc</span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;">, Class </span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">declaredType)</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637358" /><span class="DefaultParagraphFont " style="">Formatting Properties</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Usually you format the appearance of things via an object’s properties element:</span></p>
  
  <table class="TableGrid TableNormal " id="docx4j_tbl_5" style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;position: relative; margin-left: 0.47in;table-layout: fixed;vertical-align: top;border-collapse: collapse;width: 101mm;"><colgroup><col style="width: 44.09%;" /><col style="width: 55.91%;" /></colgroup><tbody><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">Object</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">Method</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">Paragraph</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">P.getPPr()</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">Run</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">R.getRPr()</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">Table</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">Tbl.getTblPr()</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">Table row</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">Tr.getTrPr()</span></p></td></tr><tr><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">Table cell</span></p></td><td style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0mm;padding-left: 1.91mm;padding-right: 1.91mm;padding-top: 0mm;">
  
  <p class="Normal-TableGrid-BR DocDefaults "><span class="" style="">Tc.getTcPr()</span></p></td></tr></tbody></table>
  
  <p class="Normal DocDefaults "> </p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">In a docx, the appearance of text is basically determined by the style in the styles part which applies to it (styles can inherit from other styles), plus any direct formatting.  </span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Docx4j contains code for working out the effective formatting, which is used in its PDF output.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">In XHTML import, docx4j converts CSS into formatting properties.</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637359" /><span class="DefaultParagraphFont " style="">Creating and adding a table</span></p>
  
  <p class="Normal DocDefaults "><a href="http://dev.plutext.org/trac/docx4j/browser/trunk/docx4j/src/main/java/org/docx4j/model/table/TblFactory.java"><span style="">org.docx4j.model.table.TblFactory</span></a><span style="white-space:pre-wrap;"> </span><span style="white-space:pre-wrap;">provides an easy way to create a simple table. For an example of its use, see the </span><a href="http://dev.plutext.org/trac/docx4j/browser/trunk/docx4j/src/main/java/org/docx4j/samples/CreateWordprocessingMLDocument.java"><span style="">CreateWordprocessingMLDocument</span><span style="white-space:pre-wrap;"> </span><span style="white-space:pre-wrap;">sample</span></a><span style="">.</span><span style="white-space:pre-wrap;">  </span><span style="white-space:pre-wrap;">If you want to add </span><span style="">content</span><span style="white-space:pre-wrap;">, see </span><a href="#_Ref273526076"><span class="DefaultParagraphFont " style="font-weight: bold;font-style: italic;">General strategy/approach for creating stuff</span></a><span style="white-space:pre-wrap;"> </span><span style="white-space:pre-wrap;">above.</span><span style="white-space:pre-wrap;">  </span><span style="">If you want format your table (make it prettier), see Formatting Properties immediately above.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Or you can use the </span><a href="http://webapp.docx4java.org/OnlineDemo/PartsList.html"><span class="Hyperlink DefaultParagraphFont " style="">PartsList</span><span class="Hyperlink DefaultParagraphFont " style="white-space:pre-wrap;"> </span><span class="Hyperlink DefaultParagraphFont " style="white-space:pre-wrap;">online </span><span class="Hyperlink DefaultParagraphFont " style="">webapp</span></a><span class="" style="white-space:pre-wrap;"> to generate the code.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">If you are looking to fill table rows with data, consider </span><span class="" style="">OpenDoPE</span><span class="" style="white-space:pre-wrap;"> content control data binding (in which you </span><span class="" style="">“</span><span class="" style="white-space:pre-wrap;">repeat</span><span class="" style="">” </span><span class="" style="white-space:pre-wrap;">a table row).</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637360" /><span class="DefaultParagraphFont " style="white-space:pre-wrap;">Selecting your insertion/editing point; </span><span class="DefaultParagraphFont "><br /><span class="" style="">accessing JAXB nodes via XPath</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">Sometimes, XPath is a succinct way to select the things you need to change.</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">You</span><span class="" style="white-space:pre-wrap;"> can use XPath to select JAXB nodes:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   MainDocumentPart</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">documentPart<span class="" style="white-space:pre-wrap;"> = </span>wordMLPackage.getMainDocumentPart();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   <span class="" style="white-space:pre-wrap;">String </span>xpath<span class="" style="white-space:pre-wrap;"> = </span></span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 8.0pt;">"//w:p"</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">;      </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   <span class="" style="white-space:pre-wrap;">List&lt;Object&gt; list = </span>documentPart.getJAXBNodesViaXPath(xpath</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">, </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">false</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">);</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">These JAXB nodes are live, in the sense that if you change them, your document changes.</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">There are a few limitations however</span><span class="" style="white-space:pre-wrap;"> in the JAXB reference implementation: </span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span style="white-space:pre-wrap;">the </span><span style="">xpath</span><span style="white-space:pre-wrap;"> </span><span style="white-space:pre-wrap;">expressions are evaluated against the XML document as it was when first opened in docx4j.  You can update the associated XML document once only, by passing true into </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">getJAXBNodesViaXPath</span><span style="">. Updating it again (with current JAXB 2.1.x or 2.2.x) will cause an error.</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span style="">For some document</span><span style="">s</span><span style="">, JAXB can</span><span>’</span><span style="">t set up the XPath</span></li></ul>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="white-space:pre-wrap;">If these limitations are causing you problems, try using </span><span class="" style="">MOXy</span><span class="" style="white-space:pre-wrap;"> as your JAXB implementation, or see Traversing immediately </span><span class="" style="">below for a different approach.</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637361" /><span class="DefaultParagraphFont " style="">Traversing a document</span></p>
  
  <p class="Normal DocDefaults "><a href="https://github.com/plutext/docx4j/blob/master/src/main/java/org/docx4j/samples/OpenMainDocumentAndTraverse.java"><span class="DefaultParagraphFont " style="color: #0000FF;text-decoration: underline;">OpenMainDocumentAndTraverse.java</span></a><span style="white-space:pre-wrap;"> </span><span style="white-space:pre-wrap;">in the samples directory shows you how to traverse the JAXB representation of a docx.  </span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">This is an alternative to XSLT, which doesn't require marshalling</span><span class="" style="white-space:pre-wrap;"> to a DOM document and </span><span class="" style="">unmarshalling</span><span class="" style="white-space:pre-wrap;"> again</span><span class="" style="">.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">The sample uses </span><span class="" style="">TraversalUtil</span><span class="" style="white-space:pre-wrap;">, which is a general approach for traversing the JAXB object tree in the main document part.  It can also be applied to headers, footers etc.   </span><span class="" style="">TraversalUtil</span><span class="" style="white-space:pre-wrap;"> has an </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">interface</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">Callback</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">, </span><span class="" style="">which you use to specify how you want to traverse the nodes, and what you want to do to them.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">As noted earlier,</span><span class="" style="white-space:pre-wrap;"> </span><span class="" style="">many objects (eg</span><span class="" style="white-space:pre-wrap;"> the document body, a paragraph, a run), have a List containing their content.  Traversal works by iterating over these lists. </span></p>
  
  <p class="Normal DocDefaults " style="border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-color: #FFFF00; border-style:solid; border-width:1px;background-color: #FFFF00;"><span class="DefaultParagraphFont " style="background-color: #FFFF00;">Traversing is a very useful approach<span class="" style="white-space:pre-wrap;"> for finding and altering parts of the document.</span></span><span class="" style="white-space:pre-wrap;">  </span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">For example, it is used in docx4j 2.8.0, to provide a way of producing HTML output without using XSLT/Xalan.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">The </span><a href="https://github.com/plutext/docx4j/tree/master/src/main/java/org/docx4j/finders"><span class="Hyperlink DefaultParagraphFont " style="">org.docx4j.finders</span></a><span class="" style="white-space:pre-wrap;"> package contains classes which make it convenient to find various objects.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">It is often superior to using XPath (owing to the limitations in the JAXB reference implementation noted above).</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Note also, in </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 10.0pt;">package</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> org.docx4j.utils:</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 10.0pt;;white-space:pre-wrap;">/** </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> * Use this if there is only a single object type (</span></span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 10.0pt;text-decoration: underline;">eg</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> just P's)</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> * you are interested in doing something with.</span></span></p>
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 10.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 10.0pt;">class</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">SingleTraversalUtilVisitorCallback</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;"> </span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">ImageConvertEmbeddedToLinked</span><span class="" style="white-space:pre-wrap;"> sample contains an example of the use of the above.</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 10.0pt;;white-space:pre-wrap;">/** </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> * Use this if there is more than one object type (</span></span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 10.0pt;text-decoration: underline;">eg</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> Tables and Paragraphs)</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 10.0pt;"><span class="" style="white-space:pre-wrap;"> * you are interested in doing something with during the traversal.</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 10.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 10.0pt;">class</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">CompoundTraversalUtilVisitorCallback</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;"> </span></p>
  
  <p class="Normal DocDefaults "> </p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Ref275255216" /><a name="_Toc532637362" /><span style="">Adding a Part</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">What if you wanted to add a new styles part? Here's how:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 9.0pt;">// Create a styles part</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;">StyleDefinitionsPart stylesPart = </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 9.0pt;;white-space:pre-wrap;">new </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">StyleDefinitionsPart();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 9.0pt;">// Populate it with default styles</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">stylesPart.unmarshalDefaultStyles();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">      </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 9.0pt;">// Add the styles part to the main document part relationships</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">wordDocumentPart.addTargetPart(stylesPart);</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">You'd take the same approach to add a header or footer.</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">When you add a part this way, it is automatically added to the source part's relationships part.</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">Generally, you'll also need to add a reference to the part (using its relationship id) to the Main Document Part.  This applies to images, headers and footers. (Comments, footnotes and endnotes are a bit different, in that what you add to the main document part are references to individual comments/footnotes/endnotes).</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637363" /><span class="DefaultParagraphFont " style="">Importing XHTML</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">docx4j can convert XHTML content (paragraphs, tables, images) into native </span><span class="" style="">WordML, reproducing much of the formatting.</span><span class="" style="white-space:pre-wrap;">  </span></p>
  
  <p class="NormalWeb Normal DocDefaults " style="border-color: #FFFFFF; border-style:solid; border-width:1px;background-color: #FFFFFF;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;">From v3, the XHTML Import functionality is a</span><span class="apple-converted-space DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;"> </span><a href="https://github.com/plutext/docx4j-ImportXHTML"><span class="Hyperlink DefaultParagraphFont " style="color: #B85B5A;font-size: 11.0pt;">separate project on GitHub</span></a><span class="apple-converted-space DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;" /><span class="DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;">.</span></p>
  
  <p class="NormalWeb Normal DocDefaults " style="border-color: #FFFFFF; border-style:solid; border-width:1px;background-color: #FFFFFF;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;">The reason being that its main dependency – Flying Saucer - is licensed under LGPL v2.1 (as opposed to ASL v2, which docx4j’s other dependencies use).</span></p>
  
  <p class="NormalWeb Normal DocDefaults " style="border-color: #FFFFFF; border-style:solid; border-width:1px;background-color: #FFFFFF;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;;white-space:pre-wrap;">If you want this functionality, you have to add these jars to your </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;">classpath.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">See the samples at </span><a href="https://github.com/plutext/docx4j-ImportXHTML/tree/master/src/samples"><span class="Hyperlink DefaultParagraphFont " style="">https://github.com/plutext/docx4j-ImportXHTML/tree/master/src/samples</span></a><span class="" style="white-space:pre-wrap;" /></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637364" /><span class="DefaultParagraphFont " style="">docx to (X)HTML</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="white-space:pre-wrap;">docx4j can convert a docx to HTML or XHTML.  </span><span class="" style="">You will find the generated HTML is clean</span><span class="" style="white-space:pre-wrap;"> (in comparison to the HTML Word produces)</span><span class="" style="">.</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">Docx4j’s HTML output is suitable for documents which contain paragraphs, tables and images.  It can’t handle more exotic features, such as equations, SmartArt, or WordArt (DrawingML</span><span class="" style="white-space:pre-wrap;"> or VML).</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">Elsewhere on the web, you’ll find XSLT which can convert docx to HTML.  That XSLT is very complex, since it has to derive effective formatting from the hierarchy.</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">In contrast, in docx4j, that logic is implemented in Java.  Because of this, docx4j’s XSLT is simple (Java XSLT extension functions do the heavy lifting).</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">In docx4j, you can create output using XSLT, or by traversing the document in Java.</span><span class="" style="white-space:pre-wrap;">  The façade lets you specify which:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">      </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;">//Prefer the exporter, that uses a </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;text-decoration: underline;">xsl</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> transformation</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">      <span class="" style="">Docx4J.</span></span><span class="DefaultParagraphFont " style="color: #000000;font-style: italic;font-size: 8.0pt;">toHTML</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">(htmlSettings</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">, </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">os, Docx4J.</span><span class="DefaultParagraphFont " style="color: #0000C0;font-style: italic;font-size: 8.0pt;">FLAG_EXPORT_PREFER_XSL</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">);</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">      </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;">//Prefer the exporter, that doesn't use a </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;text-decoration: underline;">xsl</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> transformation (= uses a visitor)</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">//      <span class="" style="">Docx4J.toHTML(</span>htmlSettings</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;">, </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;text-decoration: underline;">os</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">, Docx4J.FLAG_EXPORT_PREFER_NONXSL);</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="white-space:pre-wrap;">See the sample on GitHub at </span><a href="https://github.com/plutext/docx4j/blob/master/src/samples/docx4j/org/docx4j/samples/ConvertOutHtml.java"><span class="Hyperlink DefaultParagraphFont " style="">src</span><span class="Hyperlink DefaultParagraphFont " style="">/samples/docx4j/org/docx4j/samples/ConvertOutHtml.java</span></a><span class="" style="white-space:pre-wrap;" /></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="white-space:pre-wrap;">If you have output logging enabled, anything which is not implemented will be obvious in the output document.  </span><span class="DefaultParagraphFont " style="font-weight: bold;font-style: italic;">If debug level logging is not switched on, unsupported elements will be silently dropped.</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637365" /><span class="DefaultParagraphFont " style="">docx to PDF</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Use the Docx4J facade to convert to PDF:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">static</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">void</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">toPDF(WordprocessingMLPackage</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #6A3E3E;background-color: #FFFF00;font-size: 8.0pt;">wmlPackage</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">, </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">OutputStream</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #6A3E3E;font-size: 8.0pt;">outputStream</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">) </span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;text-indent: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">throws</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> Docx4JException </span></span></p>
  
  <p class="Normal DocDefaults "> </p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Docx4j offers several ways under the covers </span><span class="" style="">to create a PDF from a docx.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">The best results are achieved using </span><span class="" style="">Plutext’s</span><span class="" style="white-space:pre-wrap;"> commercial PDF Converter, so from version 3.3.0, docx4j defaults to using this.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">From 6.1.0, docx4j defaults to localhost endpoint for PDF Converter to avoid information leakage.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">This is controlled by docx4j property com.plutext.converter.URL</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">The localhost endpoint will only work if you download and install the converter there!  You can download an installer from </span><a href="http://converter-eval.plutext.com/"><span class="Hyperlink DefaultParagraphFont " style="">http://converter-eval.plutext.com/</span></a><span class="" style="white-space:pre-wrap;" /></p>
  
  <p class="Normal DocDefaults "><span class="" style="">If you choose to use the converter-eval.plutext.com endpoint, please only use it for light testing purposes:-</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;"><span class="" style="">com.plutext.converter.URL=http://converter-eval.plutext.com:80/v1/00000000-0000-0000-0000-000000000000/convert</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Legacy XSL FO based PDF output is in the </span><span class="" style="">docx4j-export-fo</span><span class="" style="white-space:pre-wrap;"> module</span><span class="" style="">:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="color: #008080;font-size: 8.0pt;">&lt;</span><span class="DefaultParagraphFont " style="color: #3F7F7F;font-size: 8.0pt;">groupId</span><span class="DefaultParagraphFont " style="color: #008080;font-size: 8.0pt;">&gt;</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">org.docx4j</span><span class="DefaultParagraphFont " style="color: #008080;font-size: 8.0pt;">&lt;/</span><span class="DefaultParagraphFont " style="color: #3F7F7F;font-size: 8.0pt;">groupId</span><span class="DefaultParagraphFont " style="color: #008080;font-size: 8.0pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="color: #008080;font-size: 8.0pt;">&lt;</span><span class="DefaultParagraphFont " style="color: #3F7F7F;font-size: 8.0pt;">artifactId</span><span class="DefaultParagraphFont " style="color: #008080;font-size: 8.0pt;">&gt;</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">docx4j-export-</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;text-decoration: underline;">fo</span><span class="DefaultParagraphFont " style="color: #008080;font-size: 8.0pt;">&lt;/</span><span class="DefaultParagraphFont " style="color: #3F7F7F;font-size: 8.0pt;">artifactId</span><span class="DefaultParagraphFont " style="color: #008080;font-size: 8.0pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">If you want to use the existing XSL FO + Apache FOP PDF Conversion, just add docx4j-export-fo (+ deps) to your </span><span class="" style="">classpath</span><span class="" style="white-space:pre-wrap;">.  If docx4j detects that they are present, it will revert to </span><span class="" style="">this</span><span class="" style="white-space:pre-wrap;"> FO based conversion.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">These jars are in the zip file, in </span><span class="" style="">dir</span><span class="" style="white-space:pre-wrap;"> optional/export-</span><span class="" style="">fo</span><span class="" style="white-space:pre-wrap;">  </span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637366" /><span class="DefaultParagraphFont " style="">Image Handling</span><span class="DefaultParagraphFont " style="white-space:pre-wrap;"> - DOCX</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">When you add an image to a document in Word 2007, it is generally added as a new Part (ie</span><span class="" style="white-space:pre-wrap;"> you'll find a part in the resulting docx, containing the image in base 64 format).</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">When you open the document in docx4j, docx4j will create an image part representing it.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">It is also possible to create a “linked” image.  In this case, the image is not embedded in the docx package, but rather, is referenced at its external location.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Docx4j's </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #000000;font-size: 10.0pt;">BinaryPartAbstractImage</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;"> </span><span class="" style="">class contains methods to allow you to create both embedded and linked images (along with appropriate relationships).</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">  </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;">/**</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">   </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;;white-space:pre-wrap;">* Create an image part from the provided byte array, attach it to the </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">   </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;">* main document part, and return it.*/</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">  </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 9.0pt;;white-space:pre-wrap;">public static </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">BinaryPartAbstractImage createImagePart(WordprocessingMLPackage wordMLPackage,</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">      </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 9.0pt;">byte</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;">[] bytes) </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">  </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">  </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;">/**</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">   </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;">* Create an image part from the provided byte array, attach it to the source part</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">   </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;">* (eg the main document part, a header part etc), and return it.*/</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">  </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 9.0pt;;white-space:pre-wrap;">public static </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">BinaryPartAbstractImage createImagePart(WordprocessingMLPackage wordMLPackage,</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">      </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;">Part sourcePart, </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 9.0pt;">byte</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;">[] bytes) </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">  </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;">/**</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">   </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;">* Create a linked image part, and attach it as a rel of the specified source part</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">   </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;">* (eg a header part)</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;">*/</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">  </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 9.0pt;;white-space:pre-wrap;">public static </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">BinaryPartAbstractImage createLinkedImagePart(<br /></span><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">      </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;">WordprocessingMLPackage wordMLPackage, Part sourcePart, String fileurl) </span></p>
  
  <p class="Normal DocDefaults "> </p>
  
  <p class="Normal DocDefaults "><span class="" style="">For an image to appear in the document, there also needs to be appropriate XML in the main document part.  This XML can take 2 basic forms:</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;margin-bottom: 0in;line-height: 100%;"><span style="white-space:pre-wrap;">the Word 2007 </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #800000;">w:drawing</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;;white-space:pre-wrap;"> </span><span style="">form</span></li></ul>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 9.0pt;">   </span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">&lt;w:p&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">      <span class="" style="">&lt;</span>w:r&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">         <span class="" style="">&lt;</span>w:drawing&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">            <span class="" style="">&lt;</span>wp:inline</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.0pt;">distT</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;;white-space:pre-wrap;">="0" </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.0pt;">distB</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;;white-space:pre-wrap;">="0" </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.0pt;">distL</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;;white-space:pre-wrap;">="0" </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.0pt;">distR</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;">="0"</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">               <span class="" style="">&lt;</span>wp:extent</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.0pt;">cx</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;;white-space:pre-wrap;">="3238500" </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.0pt;">cy</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;">="2362200" /</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">               <span class="" style="">&lt;</span>wp:effectExtent</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.0pt;">l</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;;white-space:pre-wrap;">="19050" </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.0pt;">t</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;;white-space:pre-wrap;">="0" </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.0pt;">r</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;;white-space:pre-wrap;">="0" </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.0pt;">b</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;">="0" /</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">               <span class="" style="">:</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">               <span class="" style="">&lt;</span>a:graphic<span class="" style="white-space:pre-wrap;"> &gt;</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">                  <span class="" style="">&lt;</span>a:graphicData</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.0pt;"><span class="" style="white-space:pre-wrap;"> ..</span></span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">                     <span class="" style="">&lt;</span>pic:pic<span class="" style="white-space:pre-wrap;"> &gt;</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">                        <span class="" style="">:</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">                        <span class="" style="">&lt;</span>pic:blipFill&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">                           <span class="" style="">&lt;</span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #800000;font-size: 9.0pt;">a:blip</span><span class="DefaultParagraphFont " style="font-weight: bold;color: #800000;font-size: 9.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #FF0000;font-size: 9.0pt;">r:embed</span><span class="DefaultParagraphFont " style="font-weight: bold;color: #0000FF;font-size: 9.0pt;">="rId5"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;"><span class="" style="white-space:pre-wrap;"> /</span></span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">                           <span class="" style="">:</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">                        <span class="" style="">&lt;</span></span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;">/</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">pic:blipFill&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">                        <span class="" style="">:</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">                     <span class="" style="">&lt;</span></span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;">/</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">pic:pic&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">                  <span class="" style="">&lt;</span></span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;">/</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">a:graphicData&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">               <span class="" style="">&lt;</span></span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;">/</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">a:graphic&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">            <span class="" style="">&lt;</span></span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;">/</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">wp:inline&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">         <span class="" style="">&lt;</span></span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;">/</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">w:drawing&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">      <span class="" style="">&lt;</span></span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;">/</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">w:r&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">   <span class="" style="">&lt;</span></span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;">/</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">w:p&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="white-space:pre-wrap;">the Word 2003 VML-based </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #800000;">w:pict</span><span style="white-space:pre-wrap;"> </span><span style="white-space:pre-wrap;">form</span></li></ul>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;">   </span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">&lt;w:p&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">      <span class="" style="">&lt;</span>w:r&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">         <span class="" style="">&lt;</span>w:pict&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">            <span class="" style="">&lt;</span>v:shapetype</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.0pt;">id</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;;white-space:pre-wrap;">="_x0000_t75" </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.0pt;">coordsize</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;;white-space:pre-wrap;">="21600,21600" </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.0pt;"><span class="" style="white-space:pre-wrap;"> .. </span></span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">               <span class="" style="">&lt;</span>v:stroke</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.0pt;">joinstyle</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;">="miter" /</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">               <span class="" style="">&lt;</span>v:formulas&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">                  <span class="" style="">:</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">               <span class="" style="">&lt;</span></span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;">/</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">v:formulas&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">               <span class="" style="">:</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">            <span class="" style="">&lt;</span></span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;">/</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">v:shapetype&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">            <span class="" style="">&lt;</span>v:shape</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.0pt;">..</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.0pt;">style</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;">="width:428.25pt;height:321pt"</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">               <span class="" style="">&lt;</span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #800000;font-size: 9.0pt;">v:imagedata</span><span class="DefaultParagraphFont " style="font-weight: bold;color: #800000;font-size: 9.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #FF0000;font-size: 9.0pt;">r:id</span><span class="DefaultParagraphFont " style="font-weight: bold;color: #0000FF;font-size: 9.0pt;">="rId4"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 9.0pt;">o:title</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;">="" /</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">            <span class="" style="">&lt;</span></span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 9.0pt;">/</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;">v:shape&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 12.0pt;">         </span><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;">&lt;</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 10.0pt;">/</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;">w:pict&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;">      <span class="" style="">&lt;</span></span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 10.0pt;">/</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;">w:r&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;">   <span class="" style="">&lt;</span></span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 10.0pt;">/</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;">w:p&gt;</span></p>
  
  <p class="Normal DocDefaults "> </p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Docx4j can create the Word 2007 </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #800000;">w:drawing/wp:inline</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 9.0pt;;white-space:pre-wrap;"> </span><span class="" style="">form for you:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">  </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;">/**</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">   </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;;white-space:pre-wrap;">* Create a </span><span class="DefaultParagraphFont " style="color: #7F7F9F;font-size: 9.0pt;;white-space:pre-wrap;">&lt;wp:inline&gt; </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;">element suitable for this image,</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">   </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;">* which can be linked or embedded in w:p/w:r/w:drawing.</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">   </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;">* If the image is wider than the page, it will be scaled</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">   </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;">* automatically.  See Javadoc for other signatures.</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">   </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;;white-space:pre-wrap;">* </span><span class="DefaultParagraphFont " style="color: #7F9FBF;font-size: 9.0pt;;white-space:pre-wrap;">@param </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;">filenameHint Any text, for example the original filename</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">   </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;;white-space:pre-wrap;">* </span><span class="DefaultParagraphFont " style="color: #7F9FBF;font-size: 9.0pt;;white-space:pre-wrap;">@param </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;">altText  Like HTML's alt text</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">   </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;;white-space:pre-wrap;">* </span><span class="DefaultParagraphFont " style="color: #7F9FBF;font-size: 9.0pt;;white-space:pre-wrap;">@param </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;">id1   An id unique in the document</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">   </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;;white-space:pre-wrap;">* </span><span class="DefaultParagraphFont " style="color: #7F9FBF;font-size: 9.0pt;;white-space:pre-wrap;">@param </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;">id2   Another id unique in the document</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">   </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;;white-space:pre-wrap;">* </span><span class="DefaultParagraphFont " style="color: #7F9FBF;font-size: 9.0pt;;white-space:pre-wrap;">@param </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #3F5FBF;font-size: 9.0pt;">link</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;"><span class="" style="white-space:pre-wrap;">  true if this is to be </span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #3F5FBF;font-size: 9.0pt;">linked not embedded</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;">*/</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">  </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 9.0pt;;white-space:pre-wrap;">public </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;">Inline createImageInline(String filenameHint, String altText, </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">      </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 9.0pt;;white-space:pre-wrap;">int </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;">id1, </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 9.0pt;;white-space:pre-wrap;">int </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;">id2, </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 9.0pt;;white-space:pre-wrap;">boolean </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;">link) </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">which you can then add to a </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #800000;">w:r/w:drawing.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Finally, with docx4j, you can convert images from formats unsupported by Word (eg</span><span class="" style="white-space:pre-wrap;"> PDF), to PNG, which is a supported format.  For this, docx4j uses </span><span class="DefaultParagraphFont " style="font-weight: bold;">ImageMagick</span><span class="" style="white-space:pre-wrap;">.  So if you want to use this feature, you need to install </span><span class="" style="">ImageMagick</span><span class="" style="white-space:pre-wrap;">.  Docx4j invokes </span><span class="" style="">ImageMagick</span><span class="" style="white-space:pre-wrap;"> using:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> Process p = Runtime.getRuntime().exec(</span></span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 8.0pt;;white-space:pre-wrap;">"imconvert -density " </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">+ density + </span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 8.0pt;">" -units PixelsPerInch - png:-"</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">);<br /></span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Note the name </span><span class="DefaultParagraphFont " style="font-weight: bold;">imconvert</span><span class="" style="white-space:pre-wrap;">, which is used so that we don't have to supply a full path to exec.  You'll need to accommodate that.  </span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637367" /><span class="DefaultParagraphFont " style="">Manual Image Manipulation</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Images involve three things:</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">the image part itself</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">a relationship, in the relationships part of the main document part (or header part etc).  This relationship includes:</span></li><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="white-space:pre-wrap;">the name of the image part (for example, </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">/word/media/image1.jpeg</span><span style="">)</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">the relationship ID</span></li></ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="white-space:pre-wrap;">some XML in the main document part (or header part etc), referencing the relationship ID (see </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #800000;">w:drawing</span><span style="white-space:pre-wrap;"> </span><span style="white-space:pre-wrap;">and </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #800000;">w:pict</span><span style="white-space:pre-wrap;"> </span><span style="white-space:pre-wrap;">examples above)</span></li></ul>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">This means that if you are moving images around, you need to take care to ensure that the relationships remain valid. </span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">You can manually manipulate the relationship, and you can manually manipulate the XML referencing the relationship IDs.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Given an image part, you can get the relationship pointing to it </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">      </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">Relationship </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">rel<span class="" style="white-space:pre-wrap;"> = </span>copiedImagePart.getSourceRelationship();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">      <span class="" style="white-space:pre-wrap;">String id = </span>rel.getId();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults "><span class="" style="">You can then ensure the reference matches.</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637368" /><span class="DefaultParagraphFont " style="">Image Handling – PPTX</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">See the pptx4j </span><a href="https://github.com/plutext/docx4j/blob/master/src/pptx4j/java/org/pptx4j/samples/InsertPicture.java"><span class="Hyperlink DefaultParagraphFont " style="">InsertPicture</span></a><span class="" style="white-space:pre-wrap;"> sample.</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637369" /><span class="DefaultParagraphFont " style="">Adding Headers/Footers</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">See the </span><span class="" style="">HeaderFooter</span><span class="" style="white-space:pre-wrap;"> sample for how to do this.</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637370" /><span class="DefaultParagraphFont " style="">Protection Settings</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">There is a family of features the Office UI groups under “Protection Settings”. These include:</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">mark as final</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">encrypt with password</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">digital signatures</span></li></ul>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Most protection settings can be manipulated using docx4j 3.3.  It contains a class </span><span class="" style="">ProtectionSettings:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;">/**</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> * The Protection Settings which are common across</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> * </span></span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;text-decoration: underline;">docx</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;;white-space:pre-wrap;">, </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;text-decoration: underline;">pptx</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;;white-space:pre-wrap;">, </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;text-decoration: underline;">xlsx</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;">, namely mark as final, encrypt with password,</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> * and digital signature.  Subclasses implement the </span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> * </span></span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;text-decoration: underline;">docx</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> and </span></span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;text-decoration: underline;">xlsx</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> format specific features.</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> * </span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> * </span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F9FBF;font-size: 8.0pt;">@author</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;text-decoration: underline;">jharrop</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> * </span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F9FBF;font-size: 8.0pt;">@since</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> 3.3.0</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> */</span></span></p>
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">abstract</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">class</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">ProtectionSettings</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">The relevant subclass is accessed via the package object:</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">WordprocessingMLPackage</span><span style="">:</span><br /><br /><span style="">ProtectDocument</span><span style="white-space:pre-wrap;"> </span><span style="">getProtectionSettings</span><span style="">()</span><br /></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">PresentationMLPackage</span><br /><br /><span style="">ProtectPresentation</span><span style="white-space:pre-wrap;"> </span><span style="">getProtectionSettings</span><span style="">()</span><br /></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">SpreadsheetMLPackage</span><br /><br /><span style="">ProtectWorkbook</span><span style="white-space:pre-wrap;"> </span><span style="">getProtectionSettings</span><span style="">()</span></li></ul>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Note: support for digital signatures is in </span><span class="" style="">Plutext’s</span><span class="" style="white-space:pre-wrap;"> Enterprise edition.</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637371" /><span class="DefaultParagraphFont " style="white-space:pre-wrap;">docx </span><span class="DefaultParagraphFont " style="">Table of Contents</span></p>
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;">From v3.3.0, docx4j can generate/update a </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">ToC</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;">, including update its page numbers.  See the </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">ToC* samples.</span></p>
  
  <p class="Heading2 Normal DocDefaults "><a name="_Toc403733683" /><a name="_Toc532637372" /><span style="">Introduction</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">A table of contents is often included in a docx file.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Where docx4j or other code is used to modify the document, the TOC may need updating since page numbers may be wrong, or entries added, deleted or modified.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">In some cases, it is sufficient to leave the TOC updating until the docx is opened in Microsoft Word.  In Word, the user can manually issue the command to update the table.  Or an AutoOpen macro can be used.   For more on this, see </span><a href="http://openxmldeveloper.org/blog/b/openxmldeveloper/archive/2011/08/24/updating-the-toc-in-a-wordprocessingml-document-using-an-autoopen-macro.aspx"><span class="Hyperlink DefaultParagraphFont " style="">http://openxmldeveloper.org/blog/b/openxmldeveloper/archive/2011/08/24/updating-the-toc-in-a-wordprocessingml-document-using-an-autoopen-macro.aspx</span></a><span class="" style="white-space:pre-wrap;" /></p>
  
  <p class="Normal DocDefaults "><span class="" style="">In other scenarios, it is desirable to update the TOC programmatically.  For example, prior to PDF output.  This TOC helper is intended to help here.</span></p>
  
  <p class="Heading2 Normal DocDefaults "><a name="_Toc403733684" /><a name="_Toc532637373" /><span style="">Field background</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Historically, Word has used a </span><span class="DefaultParagraphFont " style="font-style: italic;">field code</span><span class="" style="white-space:pre-wrap;"> to specify a table of contents.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">A table of contents field is just one type of field, amongst many:</span></p>
  
  <p class="Grammar Normal DocDefaults "><span class="DefaultParagraphFont " style="font-size: 9.0pt;">date-and-time:<br />CREATEDATE</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">DATE</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">EDITTIME</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">PRINTDATE</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">SAVEDATE</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">TIME</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  </span></p>
  
  <p class="Grammar Normal DocDefaults "><span class="DefaultParagraphFont " style="font-size: 9.0pt;">document-automation:<br />COMPARE</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">DOCVARIABLE</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">GOTOBUTTON</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">IF</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">MACROBUTTON</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">PRINT</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  </span></p>
  
  <p class="Grammar Normal DocDefaults "><span class="DefaultParagraphFont " style="font-size: 9.0pt;">document-information:<br />AUTHOR</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">COMMENTS</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">DOCPROPERTY</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">FILENAME</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">FILESIZE</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">INFO</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;"><br /><span class="" style="white-space:pre-wrap;">|  </span>KEYWORDS</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">LASTSAVEDBY</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">NUMCHARS</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">NUMPAGES</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">NUMWORDS</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">SUBJECT</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;"><br /><span class="" style="white-space:pre-wrap;">|  </span>TEMPLATE</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">TITLE</span></p>
  
  <p class="Grammar Normal DocDefaults "><span class="DefaultParagraphFont " style="font-size: 9.0pt;">equations-and-formulas:<br /><span class="" style="white-space:pre-wrap;">= formula  |  </span>ADVANCE</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">EQ</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">SYMBOL</span></p>
  
  <p class="Grammar Normal DocDefaults "><span class="DefaultParagraphFont " style="font-weight: bold;">index-and-tables:<br /></span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">INDEX</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">RD</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">TA</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">TC</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">TOA</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-weight: bold;text-decoration: underline;">TOC</span><span class="" style="white-space:pre-wrap;">  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">|  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">XE</span></p>
  
  <p class="Grammar Normal DocDefaults "><span class="DefaultParagraphFont " style="font-size: 9.0pt;">links-and-references:<br />AUTOTEXT</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">AUTOTEXTLIST</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">BIBLIOGRAPHY</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">CITATION</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">HYPERLINK</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  INCLUDEPICTURE  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">INCLUDETEXT</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;"><br /><span class="" style="white-space:pre-wrap;">|  </span>LINK</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">NOTEREF</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">PAGEREF</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">QUOTE</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">REF</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">STYLEREF</span></p>
  
  <p class="Grammar Normal DocDefaults "><span class="DefaultParagraphFont " style="font-size: 9.0pt;">mail-merge:<br />ADDRESSBLOCK</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">ASK</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">COMPARE</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">DATABASE</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">FILLIN</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">GREETINGLINE</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">IF</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;"><br /><span class="" style="white-space:pre-wrap;">|  </span>MERGEFIELD</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">MERGEREC</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">MERGESEQ</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">NEXT</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">NEXTIF</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">SET</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">SKIPIF</span></p>
  
  <p class="Grammar Normal DocDefaults "><span class="DefaultParagraphFont " style="font-size: 9.0pt;">numbering:<br />AUTONUM</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">AUTONUMLGL</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">AUTONUMOUT</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">BARCODE</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">LISTNUM</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">PAGE</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">REVNUM</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;"><br /><span class="" style="white-space:pre-wrap;">|  </span>SECTION</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">SECTIONPAGES</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">SEQ</span></p>
  
  <p class="Grammar Normal DocDefaults "><span class="DefaultParagraphFont " style="font-size: 9.0pt;">user-information:<br />USERADDRESS</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">USERINITIALS</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">  |  </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">USERNAME</span></p>
  
  <p class="Grammar Normal DocDefaults "><span class="DefaultParagraphFont " style="font-size: 9.0pt;">form-field:<br />FORMCHECKBOX</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;"> | </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">FORMDROPDOWN</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;"> | </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">FORMTEXT</span></p>
  
  <p class="Heading2 Normal DocDefaults "><a name="_Toc403733685" /><a name="_Toc532637374" /><span style="">TOC Content Control</span></p>
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="">Since the introduction of content controls in Word 2007, Word (References &gt; Table of Contents) inserts the TOC field in a content control:</span></p>
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style=""><img height="171" id="rId56" src="Docx4j_GettingStarted.docx_files/a1a5b23a-4f8e-4d6a-a032-a1ccd9afa9f2image1.png" width="468" /></span></p>
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="">When inserting a TOC, this docx4j TOC helper will insert it in a content control.</span></p>
  
  <p class="Normal DocDefaults " style="border-left-style: solid;border-left-width: 1px;border-left-color: #E36C0A;border-right-style: solid;border-right-width: 1px;border-right-color: #E36C0A;"><span class="DefaultParagraphFont " style=""><span class="" style="">When updating a TOC, this docx4j TOC helper assumes the TOC is located in such a content control.   It won’t find the TOC field unless it is.</span></span></p>
  
  <p class="Heading2 Normal DocDefaults "><a name="_Toc403733686" /><a name="_Toc532637375" /><span style="">TOC Field Syntax</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">The TOC field instruction has the following components:</span></p>
  
  <p class="Grammar Normal DocDefaults "><span class="" style="white-space:pre-wrap;">TOC </span><br /><span class="" style="white-space:pre-wrap;" /><span class="" style="">field-argument</span><br /><span class="" style="">switches</span><br /><span class="" style="">field-argument   switches</span><br /><span class="" style="">switches   field-argument</span></p>
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="white-space:pre-wrap;">The TOC field supports </span><span class="" style="">a variety of field-specific-switches.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">For example:</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;"><span class="" style="white-space:pre-wrap;">TOC \o "3-3" \h \z \t  "Heading 1,1,Heading 2,2,Appendix 1,1,Appendix 2,2" </span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Of the switches in the Open XML specification, this TOC helper recognises:</span></p>
  
  <table id="docx4j_tbl_6" style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;position: relative; margin-left: 13mm;table-layout: fixed;vertical-align: top;border-collapse: collapse;width: 129mm;"><colgroup><col style="width: 15.18%;" /><col style="width: 84.82%;" /></colgroup><tbody><tr><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="font-weight: bold;">\h</span></p></td><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="">Makes the table of contents entries hyperlinks.</span></p></td></tr><tr><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="font-weight: bold;">\n</span><span class="DefaultParagraphFont " style="white-space:pre-wrap;"> field-argument</span></p></td><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="">Without field-argument, omits page numbers from the table of contents. Page numbers are omitted from all levels unless a range of entry levels is specified by text in this switch's field-argument. A range is specified as for \l.</span></p></td></tr><tr><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="font-weight: bold;">\o</span><span class="DefaultParagraphFont " style="white-space:pre-wrap;"> field-argument</span></p></td><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="white-space:pre-wrap;">Uses paragraphs formatted with all or the specified range of built-in heading styles. Headings in a style range are specified by text in this switch's field-argument using the notation specified as for \l, where each integer corresponds to the style with a style ID of </span><span class="DefaultParagraphFont " style="">HeadingX</span><span class="DefaultParagraphFont " style="white-space:pre-wrap;"> (e.g. 1 corresponds to Heading1). If no heading range is specified, all heading levels used in the document are listed.</span></p></td></tr><tr><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="font-weight: bold;">\t</span><span class="DefaultParagraphFont " style="white-space:pre-wrap;"> field-argument</span></p></td><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="">Uses paragraphs formatted with styles other than the built-in heading styles. text in this switch's field-argument specifies those styles as a set of comma-separated doublets, with each doublet being a comma-separated set of style name and table of content level. \t can be combined with \o.</span></p></td></tr><tr><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="font-weight: bold;">\u</span></p></td><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="">Uses the applied paragraph outline level.</span></p></td></tr></tbody></table>
  
  <p class="Normal DocDefaults "> </p>
  
  <p class="Normal DocDefaults "><span class="" style="">The following switches may also be supported in a future version:</span></p>
  
  <table id="docx4j_tbl_7" style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;position: relative; margin-left: 13mm;table-layout: fixed;vertical-align: top;border-collapse: collapse;width: 129mm;"><colgroup><col style="width: 15.18%;" /><col style="width: 84.82%;" /></colgroup><tbody><tr><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="">\b field-argument</span></p></td><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="">Includes entries only from the portion of the document marked by the bookmark named by text in this switch's field-argument.</span></p></td></tr><tr><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="">\p field-argument</span></p></td><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="">text in this switch's field-argument specifies a sequence of characters that separate an entry and its page number. The default is a tab with leader dots.</span></p></td></tr><tr><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="">\w</span></p></td><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="">Preserves tab entries within table entries.</span></p></td></tr><tr><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="">\x</span></p></td><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="">Preserves newline characters within table entries.</span></p></td></tr></tbody></table>
  
  <p class="Normal DocDefaults "> </p>
  
  <p class="Normal DocDefaults "><span class="" style="">There are no plans to support the remaining switches:</span></p>
  
  <table id="docx4j_tbl_8" style="border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;position: relative; margin-left: 13mm;table-layout: fixed;vertical-align: top;border-collapse: collapse;width: 129mm;"><colgroup><col style="width: 15.18%;" /><col style="width: 84.82%;" /></colgroup><tbody><tr><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="font-size: 9.0pt;">\a field-argument</span></p></td><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="font-size: 9.0pt;">Includes captioned items, but omits caption labels and numbers. The identifier designated by text in this switch's field-argument corresponds to the caption label.</span></p>
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="font-size: 9.0pt;">Use \c to build a table of captions with labels and numbers.</span></p></td></tr><tr><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="font-size: 9.0pt;">\c field-argument</span></p></td><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="font-size: 9.0pt;">Includes figures, tables, charts, and other items that are numbered by a SEQ field. The sequence identifier designated by text in this switch's field-argument, which corresponds to the caption label, shall match the identifier in the corresponding SEQ field.</span></p></td></tr><tr><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="font-size: 9.0pt;">\d field-argument</span></p></td><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="font-size: 9.0pt;">When used with \s, the text in this switch's field-argument defines the separator between sequence and page numbers. The default separator is a hyphen (-).</span></p></td></tr><tr><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="font-size: 9.0pt;">\f field-argument</span></p></td><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="font-size: 9.0pt;">Includes only those TC fields whose identifier exactly matches the text in this switch's field-argument (which is typically a letter).</span></p></td></tr><tr><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="font-size: 9.0pt;">\l field-argument</span></p></td><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">Includes TC fields that assign entries to one of the levels specified by text in this switch's field-argument as a range having the form </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">startLevel-endLevel</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">, where </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">startLevel</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;"> and </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">endLevel</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;"> are integers, and </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">startLevel</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;"> has a value equal-to or less-than </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">endLevel. TC fields that assign entries to lower levels are skipped.</span></p></td></tr><tr><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="font-size: 9.0pt;">\s field-argument</span></p></td><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="font-size: 9.0pt;;white-space:pre-wrap;">For entries numbered with a SEQ field, adds a prefix to the page number. The </span><span class="DefaultParagraphFont " style="font-size: 9.0pt;">prefix depends on the type of entry. text in this switch's field-argument shall match the identifier in the SEQ field.</span></p></td></tr><tr><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="font-size: 9.0pt;">\z</span></p></td><td style="background-color: #FFFFFF;border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color: #000000;border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-top-style: solid;border-top-width: 1px;border-top-color: #000000;padding-bottom: 0.76mm;padding-left: 2.03mm;padding-right: 2.03mm;padding-top: 0.76mm;">
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="font-size: 9.0pt;">Hides tab leader and page numbers in Web layout view.</span></p></td></tr></tbody></table>
  
  <p class="Normal DocDefaults "> </p>
  
  <p class="Heading2 Normal DocDefaults "><a name="_Toc403733687" /><a name="_Toc532637376" /><span style="">Inserting/generating a TOC</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Assuming you have:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;">        </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">WordprocessingMLPackage</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">wordMLPackage</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;"> </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">create a </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">TocGenerator</span><span class="" style="white-space:pre-wrap;"> object:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;">        </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">TocGenerator</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">tocGenerator<span class="" style="white-space:pre-wrap;"> = </span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 10.0pt;">new</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">TocGenerator(wordMLPackage);</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Then you can insert a TOC by invoking one of the </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #000000;font-style: italic;font-size: 12.0pt;">generateToc</span><span class="DefaultParagraphFont " style="font-size: 18.0pt;;white-space:pre-wrap;"> </span><span class="" style="">methods.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">For example:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;">        </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">tocGenerator.</span><span class="DefaultParagraphFont " style="color: #000000;font-style: italic;font-size: 10.0pt;">generateToc</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;">( 0, </span><span class="DefaultParagraphFont " style="font-size: 10.0pt;">" TOC \\o \"1-3\" \\h \\z \\u "</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;">, </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 10.0pt;">false</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">);</span></p>
  
  <p class="Normal DocDefaults "> </p>
  
  <p class="Normal DocDefaults "><span class="" style="">(Note the backslash is escaped with another backslash)</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">There are 3 signatures available:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;">/**</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;">     * Generate Table of Contents as first element of body of document with default TOC instruction.</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;">     * </span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F9FBF;font-size: 8.0pt;">@param</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> body of document</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;">     * </span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F9FBF;font-size: 8.0pt;">@param</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;">skipPageNumbering<span class="" style="white-space:pre-wrap;"> don't generate page numbers (useful for HTML output, or speed, or as a </span></span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;text-decoration: underline;">fallback</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> in case of issues)</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;">     * </span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F9FBF;font-size: 8.0pt;">@return</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;">SdtBlock<span class="" style="white-space:pre-wrap;"> control</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;">     */</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">SdtBlock</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">generateToc(</span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">boolean</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">skipPageNumbering</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">) </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">throws</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">TocException</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;">/**</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;">     * Generate Table of Contents in the given place of body of document with given TOC instruction.</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;">     * See http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/TOC.html for TOC instruction.</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;">     * </span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F9FBF;font-size: 8.0pt;">@param</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> body</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;">     * </span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F9FBF;font-size: 8.0pt;">@param</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> index</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;">     * </span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F9FBF;font-size: 8.0pt;">@param</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> instruction</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;">     * </span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F9FBF;font-size: 8.0pt;">@return</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;">SdtBlock<span class="" style="white-space:pre-wrap;"> control</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;">     */</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">SdtBlock</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">generateToc(</span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">int</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> index, String instruction, </span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">boolean</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">skipPageNumbering</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">) </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">throws</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">TocException</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;">/**</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;">     * Generate Table of Contents in the given place of body of document with given TOC instruction.</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;">     * See http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/TOC.html for TOC instruction.</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;">     * </span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F9FBF;font-size: 8.0pt;">@param</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> body</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;">     * </span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F9FBF;font-size: 8.0pt;">@param</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;">sdt</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;">     * </span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F9FBF;font-size: 8.0pt;">@param</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> instruction</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;">     * </span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F9FBF;font-size: 8.0pt;">@param</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;">skipPageNumbering<span class="" style="white-space:pre-wrap;"> don't generate page numbers (useful for HTML output, or speed, or as a </span></span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;text-decoration: underline;">fallback</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> in case of issues)</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;">     * </span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F9FBF;font-size: 8.0pt;">@return</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;">SdtBlock<span class="" style="white-space:pre-wrap;"> control</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;">     */</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">static</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">SdtBlock</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">generateToc(SdtBlock</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">sdt</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">, String instruction, </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">boolean</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">skipPageNumbering</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">) </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">throws</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">TocException</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span></p>
  
  <p class="Normal DocDefaults "> </p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">You should ensure styles TOC1, TOC2, TOC3 etc are defined in your styles definition part, since these are used to style TOC entries.  </span><span class="" style="">ToC</span><span class="" style="white-space:pre-wrap;"> Helper will </span><span class="" style="">fallback</span><span class="" style="white-space:pre-wrap;"> to hard coded defaults for these styles, if they are not defined.  The hard coded defaults come from:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   InputStream<span class="" style="white-space:pre-wrap;"> is = </span>ResourceUtils.</span><span class="DefaultParagraphFont " style="color: #000000;font-style: italic;font-size: 8.0pt;">getResourceViaProperty</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">( </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;"><br />            </span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 8.0pt;">"org.docx4j.toc.TocStyles.xml"</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">,</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">            </span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 8.0pt;">"org/docx4j/toc/TocStyles.xml"</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">);</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="" style="">You can specify a different resource of your own in docx4j.properties:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;"># Defaults to </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">com/plutext/docx/toc/TocStyles.xml</span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;"># It provides default </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">toc<span class="" style="white-space:pre-wrap;"> style definitions,</span></span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;"># for use if none are defined in the </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">docx<span class="" style="white-space:pre-wrap;"> itself.</span></span></p>
  
  <p class="Normal DocDefaults " style="position: relative; margin-left: 0.5in;margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">org.docx4j.toc.TocStyles.xml=org/docx4j/toc/TocStyles.xml</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Heading2 Normal DocDefaults "><a name="_Toc403733688" /><a name="_Toc532637377" /><span style="">Page Number Considerations</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Docx4j uses </span><span class="" style="">Plutext’s</span><span class="" style="white-space:pre-wrap;"> commercial PDF Converter to work out page numbering (unless you have </span><span class="" style="">export-FO on your class path, in which case page numbering will be slower and less accurate).</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">From 6.1.0, docx4j defaults to localhost endpoint for PDF Converter to avoid information leakage; to use this, you'll need to install it; You can download an installer from </span><a href="http://converter-eval.plutext.com/"><span class="Hyperlink DefaultParagraphFont " style="">http://converter-eval.plutext.com/</span></a><span class="" style="white-space:pre-wrap;" /></p>
  
  <p class="Normal DocDefaults " style="border-left-style: solid;border-left-width: 1px;border-left-color: #E36C0A;border-right-style: solid;border-right-width: 1px;border-right-color: #E36C0A;"><span class="DefaultParagraphFont " style="">T</span><span class="DefaultParagraphFont " style="white-space:pre-wrap;">he position of the right aligned tab used for page numbers is calculated from the page width and margins, which </span><span class="DefaultParagraphFont " style="font-weight: bold;">must</span><span class="DefaultParagraphFont " style=""><span class="" style="white-space:pre-wrap;"> be provided in a </span></span><span class="DefaultParagraphFont " style="font-weight: bold;">sectPr</span><span class="DefaultParagraphFont " style=""><span class="" style="white-space:pre-wrap;"> element somewhere following the ToC.  An exception will be thrown if</span><span class="" style="white-space:pre-wrap;"> a sectPr element is not present, or doesn</span><span class="" style="">’</span><span class="" style="white-space:pre-wrap;">t contain the necessary page width / margin information.</span></span></p>
  
  <p class="Heading2 Normal DocDefaults "><a name="_Toc403733689" /><a name="_Toc532637378" /><span style="">Updating a TOC</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Assuming you have:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">        </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">WordprocessingMLPackage</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">wordMLPackage</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">create a </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">TocGenerator</span><span class="" style="white-space:pre-wrap;"> object:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;">        </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">TocGenerator</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">tocGenerator<span class="" style="white-space:pre-wrap;"> = </span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 10.0pt;">new</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">TocGenerator(wordMLPackage);</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">You can update an existing TOC by invoking </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #000000;font-style: italic;font-size: 12.0pt;">updateToc</span><span class="DefaultParagraphFont " style="font-size: 18.0pt;">.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">For example:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;">        </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">tocGenerator.</span><span class="DefaultParagraphFont " style="color: #000000;font-style: italic;font-size: 10.0pt;">updateToc</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;">( </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 10.0pt;">false</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">);</span></p>
  
  <p class="Normal DocDefaults "> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;">/**</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;">     * Update existing TOC in the document with TOC generated by </span>generateToc() method.</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;">     * </span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F9FBF;font-size: 8.0pt;">@param</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> body</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;">     * </span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F9FBF;font-size: 8.0pt;">@param</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;">skipPageNumbering<span class="" style="white-space:pre-wrap;"> don't generate page numbers (useful for HTML output, or speed, or as a </span></span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;text-decoration: underline;">fallback</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> in case of issues)</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;">     * </span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F9FBF;font-size: 8.0pt;">@return</span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;">SdtBlock<span class="" style="white-space:pre-wrap;"> control, or null if no TOC was founds</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;">     */</span></span></p>
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">SdtBlock</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">updateToc(</span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">boolean</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">skipPageNumbering</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">) </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">throws</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">TocException</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">As above, </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">boolean</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">skipPageNumbering</span><span class="" style="white-space:pre-wrap;"> argument is provided so you can control whether the helper generates indicative page numbers or not.</span></p>
  
  <p class="Heading2 Normal DocDefaults "><a name="_Toc403733690" /><a name="_Toc532637379" /><span style="">Known Issues</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">ToC</span><span style="white-space:pre-wrap;"> </span><span style="white-space:pre-wrap;">in a table cell:  the position of the right aligned tab will be calculated incorrectly.</span></li></ul>
  
  <p class="Normal DocDefaults "> </p>
  
  <p class="Normal DocDefaults "> </p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637380" /><span class="DefaultParagraphFont " style="">Text extraction</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">A quick way to extract the text from a docx, is to use </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;"><span class="" style="white-space:pre-wrap;">TextUtils</span><span class="" style="">‘  </span></span></p>
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">  </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 9.0pt;;white-space:pre-wrap;">public static void </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">extractText(Object o, Writer w)</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">which marshals the object it is passed via a SAX </span><span class="" style="">ContentHandler, in order to output the text to the Writer.</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637381" /><span class="DefaultParagraphFont " style="">Text substitution</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Text substitution is easy enough, provided the string you are searching for is represented in a </span><span class="DefaultParagraphFont " style="font-weight: bold;;white-space:pre-wrap;">org.docx4j.wml.Text </span><span class="" style="">object in the form you expect.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">However, that won't necessarily be the case.  The string could be broken across text runs for any of the following reasons:</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">part of the word is formatted differently (</span><span style="">eg</span><span style="white-space:pre-wrap;"> </span><span style="white-space:pre-wrap;">in bold)</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">spelling/grammar</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">editing order (</span><span style="">rsid</span><span style="">)</span></li></ul>
  
  <p class="Normal DocDefaults "><span class="" style="">This is one reason that using data bound content controls is often a better approach (see next section).</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Subject to that, you can do text substitution in a variety of ways, for example:</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="white-space:pre-wrap;">traversing the main document part, and looking at the </span><span class="DefaultParagraphFont " style="font-weight: bold;;white-space:pre-wrap;">org.docx4j.wml.Text </span><span style="">objects</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="white-space:pre-wrap;">marshal to a string, search/replace in that, then unmarshall again </span></li></ul>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">docx4j</span><span class="" style="">‘</span><span class="" style="white-space:pre-wrap;">s </span><span class="" style="">XmlUtils</span><span class="" style="white-space:pre-wrap;"> also contains:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">     </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;">/**</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">     </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;">* Give a string of wml containing ${key1}, ${key2}, return a suitable</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">     </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;">* object.*/</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 9.0pt;;white-space:pre-wrap;">public static </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;">Object unmarshallFromTemplate(String wmlTemplateString, </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">        </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;">java.util.HashMap&lt;String, String&gt; mappings) </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;"><br /></span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">See the </span><span class="" style="">UnmarshallFromTemplate</span><span class="" style="white-space:pre-wrap;"> example, which operates on a string containing:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="font-size: 12.0pt;">   </span><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;">&lt;w:p&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;">      <span class="" style="">&lt;</span>w:r&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;">         <span class="" style="">&lt;</span>w:t&gt;</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;">My favourite colour is </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #000000;font-size: 10.0pt;">${colour}</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">.</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;">&lt;</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 10.0pt;">/</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;">w:t&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;">      <span class="" style="">&lt;</span></span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 10.0pt;">/</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;">w:r&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;">   <span class="" style="">&lt;</span></span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 10.0pt;">/</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;">w:p&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;">   <span class="" style="">&lt;</span>w:p</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 10.0pt;">/</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;">   <span class="" style="">&lt;</span>w:p&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;">      <span class="" style="">&lt;</span>w:r&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;">         <span class="" style="">&lt;</span>w:t&gt;</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;;white-space:pre-wrap;">My favourite ice cream is </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #000000;font-size: 10.0pt;">${icecream}</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 10.0pt;">.</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;">&lt;</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 10.0pt;">/</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;">w:t&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;">      <span class="" style="">&lt;</span></span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 10.0pt;">/</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;">w:r&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;">   <span class="" style="">&lt;</span></span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 10.0pt;">/</span><span class="DefaultParagraphFont " style="color: #800000;font-size: 10.0pt;">w:p&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637382" /><span class="DefaultParagraphFont " style="">Text substitution via data bound content controls</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">If you have an XML file containing your own data, </span><span class="" style="">WordML</span><span class="" style="white-space:pre-wrap;"> has a </span><span class="" style="">mechansim</span><span class="" style="white-space:pre-wrap;"> for associating entries in that XML with content controls in the document.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Then, when you open the document in Word 2007, Word automatically populates the content controls with the relevant XML data, which could even be an image (or with docx4j, arbitrary XHTML)</span><span class="" style="white-space:pre-wrap;">.  (This approach supersedes Word's legacy mail merge fields.  Simple VBA for migrating a document is available at </span><a href="http://blogs.msdn.com/b/microsoft_office_word/archive/2007/03/28/migrating-mail-merge-fields-to-content-controls.aspx"><span class="Hyperlink DefaultParagraphFont " style="font-size: 9.0pt;">http://blogs.msdn.com/b/microsoft_office_word/archive/2007/03/28/migrating-mail-merge-fields-to-content-controls.aspx</span></a><span class="" style="white-space:pre-wrap;"> )</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">This works using XPath.  A data-bound content control looks something like:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;"><span class="" style="white-space:pre-wrap;">      &lt;</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 7.5pt;">w:sdt</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;"><span class="" style="white-space:pre-wrap;">        &lt;</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 7.5pt;">w:sdtPr</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;"><span class="" style="white-space:pre-wrap;">          &lt;</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 7.5pt;">w:dataBinding</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 7.5pt;">w:xpath</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;">=</span><span class="DefaultParagraphFont " style="font-size: 7.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;">/root[1]/customer[1]</span><span class="DefaultParagraphFont " style="font-size: 7.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 7.5pt;">w:storeItemID</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;">=</span><span class="DefaultParagraphFont " style="font-size: 7.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;">{428C88D8-C0E3-44F0-B5D7-F65D8B9F7EC9}</span><span class="DefaultParagraphFont " style="font-size: 7.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;"><span class="" style="white-space:pre-wrap;"> /&gt;</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;"><span class="" style="white-space:pre-wrap;">        &lt;/</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 7.5pt;">w:sdtPr</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;"><span class="" style="white-space:pre-wrap;">        &lt;</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 7.5pt;">w:sdtContent</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;"><span class="" style="white-space:pre-wrap;">          &lt;</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 7.5pt;">w:r</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;"><span class="" style="white-space:pre-wrap;">            &lt;</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 7.5pt;">w:rPr</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;"><span class="" style="white-space:pre-wrap;">              &lt;</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 7.5pt;">w:rStyle</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #FF0000;font-size: 7.5pt;">w:val</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;">=</span><span class="DefaultParagraphFont " style="font-size: 7.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;">PlaceholderText</span><span class="DefaultParagraphFont " style="font-size: 7.5pt;">"</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;"><span class="" style="white-space:pre-wrap;"> /&gt;</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;"><span class="" style="white-space:pre-wrap;">            &lt;/</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 7.5pt;">w:rPr</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;"><span class="" style="white-space:pre-wrap;">            &lt;</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 7.5pt;">w:t</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;">&gt;</span><span class="DefaultParagraphFont " style="font-size: 7.5pt;">Click here to enter text.</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;">&lt;/</span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 7.5pt;">w:t</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;"><span class="" style="white-space:pre-wrap;">          &lt;/</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 7.5pt;">w:r</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;"><span class="" style="white-space:pre-wrap;">        &lt;/</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 7.5pt;">w:sdtContent</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;"><span class="" style="white-space:pre-wrap;">      &lt;/</span></span><span class="DefaultParagraphFont " style="color: #A31515;font-size: 7.5pt;">w:sdt</span><span class="DefaultParagraphFont " style="color: #0000FF;font-size: 7.5pt;">&gt;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">You XML file is stored as a part in the docx, typically with a path which is something like </span><span class="" style="">customXml/item1.xml.   Note: despite the word "customXml" in the path, this functionality is not affected by the 2009 i4i patent saga.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">If you have a Word document which contains data-bound content controls and your data, docx4j can fetch the data, and place it in the relevant content controls.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">This is useful if you don't want to leave it to Word to do that (for example, you are creating PDFs with docx4j).</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Your XML is represented using 2 parts:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">      CustomXmlDataStoragePart</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">customXmlDataStoragePart</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">         <span class="" style="white-space:pre-wrap;">= </span>wordMLPackage.getCustomXmlDataStorageParts().get(itemId);</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">      CustomXmlDataStorage</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">customXmlDataStorage</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">         <span class="" style="white-space:pre-wrap;">= </span>customXmlDataStoragePart.getData();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults "><span class="" style="">To apply the bindings:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">      <span class="" style="">customXmlDataStoragePart.</span></span><span class="DefaultParagraphFont " style="color: #000000;font-style: italic;font-size: 8.0pt;">applyBindings</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">(wordMLPackage.getMainDocumentPart());</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">See further the </span><span class="" style="">CustomXmlBinding</span><span class="" style="white-space:pre-wrap;"> sample. </span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">If you want to create the same document 5 times, each populated with different data, obviously you'd need to insert new XML data first.</span></p>
  
  <p class="Heading2 Normal DocDefaults "><a name="_Toc532637383" /><span style="">Binding extensions for repeats and conditionals</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">A content control is </span><span class="DefaultParagraphFont " style="font-style: italic;">conditional</span><span class="" style="white-space:pre-wrap;"> if it (and its contents) are included/excluded from the document based on whether some condition is true or false.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">A content control is a </span><span class="DefaultParagraphFont " style="font-style: italic;">repeat</span><span class="" style="white-space:pre-wrap;"> if it designates that its contents are to be included more than once.  For example, a row of a table for each invoice/order item, or person.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">docx4j contains a mechanism for processing conditional content controls and repeats.  See </span><a href="http://www.opendope.org/opendope_conventions_v2.3.html"><span class="Hyperlink DefaultParagraphFont " style="">http://www.opendope.org/opendope_conventions_v2.3.html</span></a><span class="" style="white-space:pre-wrap;"> for an explanation.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">See also the docx4j sample </span><span class="" style="">ContentControlBindingExtensions.</span></p>
  
  <p class="Heading2 Normal DocDefaults "><a name="_Toc532637384" /><span style="">Binding escaped XHTML (XML + CSS)</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">docx4j can also take encoded XHTML and convert this to docx content.</span><span class="" style="white-space:pre-wrap;"> See further OpenDoPE_XHTML.docx in the docx4j docs directory.</span></p>
  
  <p class="Heading2 Normal DocDefaults "><a name="_Toc532637385" /><span style="">Binding other rich content</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">docx4j can take docx content (stored in an XML element as escaped Flat OPC XML) and convert this to docx content. </span></p>
  
  <p class="Heading2 Normal DocDefaults "><a name="_Toc532637386" /><span style="">Authoring</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">To set up the bindings, you can use one of the Word Add-In from </span><a href="http://www.opendope.org/implementations.html"><span class="Hyperlink DefaultParagraphFont " style="">http://www.opendope.org/implementations.html</span></a><span class="" style="white-space:pre-wrap;">  Please note that you will need to install .NET Framework 4.0 ("full" - the "client profile" is not enough).</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637387" /><span class="DefaultParagraphFont " style="">Mailmerge</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">docx4j has quite good support for processing fields of type MERGEFIELD (ie</span><span class="" style="white-space:pre-wrap;"> the equivalent of doing a </span><span class="" style="">mailmerge</span><span class="" style="white-space:pre-wrap;"> operation from within Microsoft Word).</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637388" /><span style="">SmartArt</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">docx4j supports reading docx and pptx files which contain SmartArt.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">From docx4j 2.7.0, you can also generate SmartArt.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">To do this, you need:</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="white-space:pre-wrap;">the layout definition for the SmartArt, either in the docx already, or from a </span><span style="">glox</span><span style="white-space:pre-wrap;"> </span><span style="white-space:pre-wrap;">file </span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">an XML file specifying the list of text items you want to render graphically</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">an XSLT which can convert a transformed version of that XML file into a SmartArt data file.</span></li></ul>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Docx4j can be used to insert the SmartArt parts into a docx; Word or </span><span class="" style="">Powerpoint</span><span class="" style="white-space:pre-wrap;"> will then render it when the document is opened.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">The code can be found in:</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">org.opendope.SmartArt.dataHierarchy</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">org.docx4j.openpackaging.parts.DrawingML, and</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">src</span><span style="">/glox4j/java</span></li></ul>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637389" /><span style="">JAXB stuff</span></p>
  
  <p class="Heading2 Normal DocDefaults "><a name="_Toc532637390" /><span style="">Cloning</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="white-space:pre-wrap;">To clone a JAXB object, use one of the following methods in </span><span class="" style="">XmlUtils:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">  </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;;white-space:pre-wrap;">/** Clone this JAXB object, using default JAXBContext. */ </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">  </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 9.0pt;;white-space:pre-wrap;">public static </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;">&lt;T&gt; T deepCopy(T value) </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">  </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">  </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;">/** Clone this JAXB object */</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">  </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 9.0pt;;white-space:pre-wrap;">public static </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;">&lt;T&gt; T deepCopy(T value, JAXBContext jc) </span></p>
  
  <p class="Heading2 Normal DocDefaults "><a name="_Toc532637391" /><a name="_Ref273527051" /><span class="DefaultParagraphFont " style="">javax.xml.bind.JAXBElement</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">One annoying thing about JAXB, is that an object </span><span class="" style="">– </span><span class="" style="white-space:pre-wrap;">say a table </span><span class="" style="">– </span><span class="" style="white-space:pre-wrap;">could be represented as </span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 9.0pt;">org.docx4j.wml.Tbl</span><span class="" style="white-space:pre-wrap;"> (as you would expect).  Or it might be wrapped in a </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #000000;font-size: 9.0pt;">javax.xml.bind.JAXBElement</span><span class="" style="">, in which case to get the real table, you have to do something like:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">     </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 9.0pt;;white-space:pre-wrap;">if </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">( ((JAXBElement)o).getDeclaredType().getName().equals(</span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 9.0pt;">"org.docx4j.wml.Tbl"</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;">) ) </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">          </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">org.docx4j.wml.Tbl tbl = (org.docx4j.wml.Tbl)((JAXBElement)o).getValue();</span></p>
  
  <p class="Normal DocDefaults "> </p>
  
  <p class="Normal DocDefaults "><span class="" style="">XmlUtils.</span><span class="DefaultParagraphFont " style="font-weight: bold;">unwrap</span><span class="" style="white-space:pre-wrap;"> can do this for you.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Be careful, though.  If you are intend to copy an unwrapped object into your document (rather than just read it), you'll probably want the object to remain wrapped (JAXB usually wraps them for a reason; without the wrapper, you might find you need an @XmlRootElement</span><span class="" style="white-space:pre-wrap;"> annotation in order to be able to </span><span class="" style="">marshall</span><span class="" style="white-space:pre-wrap;"> </span><span class="" style="">ie</span><span class="" style="white-space:pre-wrap;"> save your document).</span></p>
  
  <p class="Heading2 Normal DocDefaults "><a name="_Toc532637392" /><span style="">@</span><span style="">XmlRootElement</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Most commonly used objects have an </span><span class="DefaultParagraphFont " style="font-weight: bold;">@XmlRootElement</span><span class="DefaultParagraphFont " style="font-weight: bold;;white-space:pre-wrap;"> </span><span class="" style="white-space:pre-wrap;">annotation, so they can be marshalled and unmarshalled.  </span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="white-space:pre-wrap;">In some cases, you might find this annotation is missing.  </span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="white-space:pre-wrap;">If you can't add the annotation to the </span><span class="" style="">jaxb</span><span class="" style="white-space:pre-wrap;"> source code, an alternative is to </span><span class="DefaultParagraphFont " style="text-decoration: underline;">marshall</span><span class="" style="white-space:pre-wrap;"> it using code which is explicit about the resulting </span><span class="" style="">QName</span><span class="" style="white-space:pre-wrap;">.  For example, </span><span class="" style="">XmlUtils</span><span class="" style="white-space:pre-wrap;"> contains:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">  </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;">/** Marshal to a W3C document, for object</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">   </span><span class="DefaultParagraphFont " style="color: #3F5FBF;font-size: 9.0pt;">*  missing an @XmlRootElement annotation.  */</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">  </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 9.0pt;;white-space:pre-wrap;">public static </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">org.w3c.dom.Document marshaltoW3CDomDocument(Object o, JAXBContext jc,</span><span class="DefaultParagraphFont " style="font-size: 9.0pt;"><br /></span><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">      </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;">String uri, String local, Class declaredType) </span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">You could use this like so:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;">CTFootnotes footnotes = </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;"><br /></span><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">        </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">wmlPackage.getMainDocumentPart().getFootnotesPart().getJaxbElement().getValue();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">CTFtnEdn ftn = footnotes.getFootnote().get(1);</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 9.0pt;;white-space:pre-wrap;">// No @XmlRootElement on CTFtnEdn, so .. </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">Document d = XmlUtils.marshaltoW3CDomDocument( ftn,</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #FFFFFF;font-size: 9.0pt;;white-space:pre-wrap;">        </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;">Context.jc, Namespaces.NS_WORD12, </span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 9.0pt;">"footnote"</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">,  CTFtnEdn.</span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 9.0pt;;white-space:pre-wrap;">class </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">);</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="apple-style-span DefaultParagraphFont " style="color: #000000;;white-space:pre-wrap;">Where the problematic object is something you're adding which isn't at the top of the tree, you should add it wrapped in a </span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;">JAXBElement</span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;;white-space:pre-wrap;">.  For example, suppose you wanted to add </span><span class="DefaultParagraphFont " style="color: #000000;">FldChar</span><span class="DefaultParagraphFont " style="color: #000000;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;">fldchar.  You'd create it in the ordinary way:</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">FldChar</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 9.0pt;">fldchar<span class="" style="white-space:pre-wrap;"> = </span>factory.createFldChar();</span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="apple-style-span DefaultParagraphFont " style="color: #000000;;white-space:pre-wrap;">but then what you'd actually add to </span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;">r.getRunContent() is:</span><span class="DefaultParagraphFont " style="color: #000000;">   </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">new</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">JAXBElement</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">( </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">new</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">QName(Namespaces.</span><span class="DefaultParagraphFont " style="color: #0000C0;font-style: italic;font-size: 8.0pt;">NS_WORD12</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">, </span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 8.0pt;">"fldChar"</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">), </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">FldChar.</span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">class</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">, </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">fldchar);</span><span class="apple-style-span DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="">An easier way to do this is to find the appropriate method in the object factory (ie</span><span class="" style="white-space:pre-wrap;"> the method for creating it wrapped as a </span><span class="" style="">JAXBElement).  Use that method signature.  In this example:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="color: #646464;font-size: 8.0pt;">@XmlElementDecl</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">(namespace = </span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 8.0pt;">"http://schemas.openxmlformats.org/wordprocessingml/2006/main"</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">, name = </span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 8.0pt;">"fldChar"</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">, scope = </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">R.</span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">class</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">)</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">    </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">public</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">JAXBElement&lt;FldChar</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">&gt; </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">createRFldChar(FldChar<span class="" style="white-space:pre-wrap;"> value) {</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">        </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">return</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">new</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">JAXBElement&lt;FldChar&gt;(</span><span class="DefaultParagraphFont " style="color: #0000C0;font-style: italic;font-size: 8.0pt;">_RFldChar_QNAME</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">, </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">FldChar.</span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">class</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;">, </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">R.</span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">class</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">, value);</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;">    }</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-top: 0.07in;margin-bottom: 0.07in;line-height: 100%;"><span class="" style="white-space:pre-wrap;">The easiest way is to use the </span><a href="http://webapp.docx4java.org/OnlineDemo/PartsList.html"><span class="Hyperlink DefaultParagraphFont " style="">PartsList</span><span class="Hyperlink DefaultParagraphFont " style="white-space:pre-wrap;"> </span><span class="Hyperlink DefaultParagraphFont " style="white-space:pre-wrap;">online </span><span class="Hyperlink DefaultParagraphFont " style="">webapp</span></a><span class="" style="white-space:pre-wrap;"> to generate the relevant code.</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637393" /><span class="DefaultParagraphFont " style="">Merging Documents and Presentations</span></p>
  
  <p class="NormalWeb Normal DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;">As</span><span class="apple-converted-space DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;"> </span><a href="http://blogs.msdn.com/b/ericwhite/archive/2008/11/03/inserting-deleting-moving-paragraphs-in-open-xml-wordprocessing-documents.aspx"><span class="Hyperlink DefaultParagraphFont " style="color: #AD582A;font-size: 11.0pt;"><span class="" style="">Eric White’s blog explained</span></span></a><span class="apple-converted-space DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;" /><span class="DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;">, combining multiple documents can be complicated:</span></p>
  
  <p class="NormalWeb Normal DocDefaults " style="position: relative; margin-left: 0.5in;"><span class="DefaultParagraphFont " style="color: #777777;font-size: 11.0pt;;white-space:pre-wrap;">This programming task is complicated by the need to keep other parts of the document in sync with the data stored in paragraphs. For example, a paragraph can contain a reference to a comment in the comments part, and if there is a problem with this reference, the </span><span class="DefaultParagraphFont " style="color: #777777;font-size: 11.0pt;">document is invalid. You must take care when moving / inserting / deleting paragraphs to maintain ‘</span><span class="Emphasis DefaultParagraphFont " style="font-weight: bold;color: #777777;font-size: 11.0pt;">referential integrity</span><span class="DefaultParagraphFont " style="color: #777777;font-size: 11.0pt;">’ within the document.</span></p>
  
  <p class="NormalWeb Normal DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;">Plutext’s</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;;white-space:pre-wrap;"> Enterprise edition of docx4j includes “</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;">MergeDocx” code  which makes merging documents as easy as invoking the method:</span></p>
  
  <p class="Normal DocDefaults "><span class="HTMLCode DefaultParagraphFont " style="font-size: 8.0pt;">   <span class="" style="">public</span></span><span class="DefaultParagraphFont " style="font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;">  </span></span><span class="HTMLCode DefaultParagraphFont " style="font-size: 8.0pt;">WordprocessingMLPackage<span class="" style="white-space:pre-wrap;"> merge(List&lt;</span>WordprocessingMLPackage<span class="" style="">&gt; </span>wmlPkgs)</span></p>
  
  <p class="NormalWeb Normal DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;">In other words, you pass a list of docx, and get a single new docx back.</span></p>
  
  <p class="NormalWeb Normal DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;;white-space:pre-wrap;">To try it, visit </span><a href="http://webapp.docx4java.org/"><span class="Hyperlink DefaultParagraphFont " style="">http://webapp.docx4java.org/</span></a><span class="DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;;white-space:pre-wrap;" /></p>
  
  <p class="NormalWeb Normal DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;;white-space:pre-wrap;">The commercial edition of docx4j includes </span><span class="DefaultParagraphFont " style="font-size: 11.0pt;">MergePptx, which you can use to concatenate presentations.</span></p>
  
  <p class="NormalWeb Normal DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;;white-space:pre-wrap;">The </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;">MergeDocx</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;;white-space:pre-wrap;"> extension can also be used to process a </span><span class="DefaultParagraphFont " style="font-weight: bold;color: #000000;font-size: 11.0pt;">docx</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;;white-space:pre-wrap;"> which is embedded as an</span><span class="apple-converted-space DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;"> </span><span class="Strong DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;">altChunk</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;;white-space:pre-wrap;">.  (Without the extension, you have to rely on Word to convert the </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;">altChunk</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;;white-space:pre-wrap;"> to normal content, which means if your docx contains w:altChunk, you have to round trip it through Word, before docx4j can create a PDF or HTML out of it.)</span></p>
  
  <p class="NormalWeb Normal DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;">To process the w:altChunk elements in a docx, you invoke:</span></p>
  
  <p class="Normal DocDefaults "><span class="HTMLCode DefaultParagraphFont " style="font-size: 8.0pt;">   <span class="" style="">public</span></span><span class="DefaultParagraphFont " style="font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="HTMLCode DefaultParagraphFont " style="font-size: 8.0pt;">WordprocessingMLPackage<span class="" style="white-space:pre-wrap;"> process(</span>WordprocessingMLPackage</span><span class="HTMLCode DefaultParagraphFont " style="font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="HTMLCode DefaultParagraphFont " style="font-size: 8.0pt;">srcPackage)</span></p>
  
  <p class="NormalWeb Normal DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;;white-space:pre-wrap;">You pass in a docx </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;">containg</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 11.0pt;">altChunks, and get a  new docx back which doesn’t.</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637394" /><span class="DefaultParagraphFont " style="">Other Support Options</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">If the free community support available in the docx4j forum does not meet your needs, or you simply want to outsource some coding, you are welcome to purchase programming, consulting </span><span class="" style="">or</span><span class="" style="white-space:pre-wrap;"> priority support from </span><a href="http://www.plutext.com/m/index.php/services"><span class="Hyperlink DefaultParagraphFont " style="font-size: 10.0pt;">Plutext</span></a><span class="" style="white-space:pre-wrap;" /></p>
  
  <p class="Normal DocDefaults "><span class="" style="">By purchasing services from Plutext, you support the continued development of docx4j.</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637395" /><span class="DefaultParagraphFont " style="">Colophon</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">This document was written in Word 2007</span><span class="" style="white-space:pre-wrap;"> (and more recently 2010)</span><span class="" style="">, using:</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="white-space:pre-wrap;">XML pretty printed using </span><a href="http://www.softlion.com/webTools/XmlPrettyPrint/default.aspx"><span class="DefaultParagraphFont " style="color: #0000FF;text-decoration: underline;">http://www.softlion.com/webTools/XmlPrettyPrint/default.aspx</span></a><span style="white-space:pre-wrap;"> </span><span style="white-space:pre-wrap;">or Package Explorer</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="white-space:pre-wrap;">Java source code formatted using </span><a href="http://www.java2html.de"><span class="Hyperlink DefaultParagraphFont " style="">http://www.java2html.de</span></a><span style="white-space:pre-wrap;"> </span><span style="white-space:pre-wrap;">(or cut/pasted from Eclipse)</span></li></ul>
  
  <p class="Normal DocDefaults "><span class="" style="">The PDF and HTML versions were generated using docx4j (PDF via XSL FO and FOP).</span></p>
  
  <p class="Heading1 Normal DocDefaults "><a name="_Toc532637396" /><span class="DefaultParagraphFont " style="">Contacting Plutext</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Unless you have paid for support, general </span><span class="" style="">“</span><span class="" style="white-space:pre-wrap;">How do I</span><span class="" style="">” </span><span class="" style="white-space:pre-wrap;">type questions should be posted directly to the </span><a href="http://www.docx4java.org/forums/"><span class="Hyperlink DefaultParagraphFont " style="">docx4j forum</span></a><span class="" style="white-space:pre-wrap;"> or </span><span class="" style="">StackOverflow.</span><span class="" style="white-space:pre-wrap;">  Plutext may post to the forum any questions it receives by email which should have been directed to the forum.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Plutext can be contacted at either </span><a href="mailto:jason@plutext.org"><span class="Hyperlink DefaultParagraphFont " style="">jason@plutext.org</span></a><span class="" style="white-space:pre-wrap;">, or </span><a href="mailto:jharrop@plutext.com"><span class="Hyperlink DefaultParagraphFont " style="">jharrop@plutext.com</span></a><span class="" style="white-space:pre-wrap;" /></p>
  
  <p class="Normal DocDefaults " style="page-break-before: always;"> </p>
  
  <p class="Normal DocDefaults "> </p>
  
  <p class="Normal DocDefaults " style="text-align: center;"><span class="DefaultParagraphFont " style="font-weight: bold;text-decoration: underline;;white-space:pre-wrap;">Appendix </span><span class="DefaultParagraphFont " style="font-weight: bold;text-decoration: underline;">1<span class="" style="white-space:pre-wrap;"> </span><span class="" style="">– </span>Font Mapping</span></p>
  
  <p class="Normal DocDefaults " style="border-left-style: solid;border-left-width: 1px;border-left-color: #000000;border-right-style: solid;border-right-width: 1px;border-right-color: #000000;border-color: #FFFF00; border-style:solid; border-width:1px;background-color: #FFFF00;"><span class="" style="white-space:pre-wrap;">This section is not relevant if you are using </span><span class="" style="">Plutext’s</span><span class="" style="white-space:pre-wrap;"> PDF Converter for PDF output.  The PDF Converter uses the most appropriate fonts installed and available to it. </span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">docx4j can only use fonts which are available to it.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">These fonts come from 2 sources:</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">those installed on the computer</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">those embedded in the document</span></li></ul>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">Note that Word silently performs </span><span class="DefaultParagraphFont " style="font-weight: bold;font-style: italic;">font substitution</span><span class="" style="white-space:pre-wrap;">.  When you open an existing document in Word, and select text in a particular font, the actual font you see on the screen won't be the font reported in the ribbon if it is not installed on your computer or embedded in the document.  To see whether Word 2007 is substituting a font, go into Word Options &gt; Advanced &gt; Show Document Content and press the "Font Substitution" button.  </span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">Word's font substitution information is not available to docx4j.  As a developer, you 3 options:</span></p><ul>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">ensure the font is installed or embedded</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">tell docx4j which font to use instead, or</span></li>
  
  <li class="ListParagraph Normal DocDefaults " style="display: list-item;"><span style="">allow docx4j to fallback to a default font</span></li></ul>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">To embed a font in a document, open it in Word on a computer which has the font installed (check no substitution is </span><span class="" style="">occuring), and go to Word Options &gt; Save &gt; Embed Fonts in File.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">If you want to tell docx4j to use a different font, you need to add a font mapping.  The </span><span class="" style="">FontMapper</span><span class="" style="white-space:pre-wrap;"> interface is used to do this.</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">On a Windows computer, font names for installed fonts are mapped 1:1 to the corresponding physical fonts via the </span><span class="" style="">IdentityPlusMapper</span><span class="" style="white-space:pre-wrap;">. </span></p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">A font mapper contains Map&lt;String, </span><span class="" style="">PhysicalFont</span><span class="" style="white-space:pre-wrap;">&gt;; to add a font mapping, as per the example in the </span><span class="" style="">ConvertOutPDF</span><span class="" style="white-space:pre-wrap;"> sample:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;">// Set up font </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;text-decoration: underline;">mapper</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   <span class="" style="white-space:pre-wrap;">Mapper </span>fontMapper<span class="" style="white-space:pre-wrap;"> = </span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">new</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">IdentityPlusMapper();</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   wordMLPackage.setFontMapper(fontMapper);</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">         </span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;">// Example of mapping missing font Algerian to installed font Comic </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;text-decoration: underline;">Sans</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> MS</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   PhysicalFont<span class="" style="white-space:pre-wrap;"> font = </span>PhysicalFonts.</span><span class="DefaultParagraphFont " style="color: #000000;font-style: italic;font-size: 8.0pt;">getPhysicalFonts</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">().get(</span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 8.0pt;">"Comic Sans MS"</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">);</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   fontMapper.getFontMappings().put(</span><span class="DefaultParagraphFont " style="color: #2A00FF;font-size: 8.0pt;">"Algerian"</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">, font);</span></p>
  
  <p class="Normal DocDefaults "> </p>
  
  <p class="Normal DocDefaults "><span class="" style="white-space:pre-wrap;">You'll see the font names if you configure log4j debug level logging for </span><span class="DefaultParagraphFont " style="font-weight: bold;font-size: 9.0pt;">org.docx4j.fonts.PhysicalFonts</span></p>
  
  <p class="Normal DocDefaults "><span class="" style="">To conserve resources, you can restrict to a subset of fonts installed on your system:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;">// Font </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;text-decoration: underline;">regex</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> (optional)</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;">// Set </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;text-decoration: underline;">regex</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;"><span class="" style="white-space:pre-wrap;"> if you want to restrict to some defined subset of fonts</span></span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;">// Here we have to do this before calling </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">createContent,</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">// since that discovers fonts</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   <span class="" style="white-space:pre-wrap;">String regex = </span></span><span class="DefaultParagraphFont " style="font-weight: bold;color: #7F0055;font-size: 8.0pt;">null</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">;</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">// Windows:</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">// String</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 6.0pt;">   </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 6.0pt;;white-space:pre-wrap;">// </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 6.0pt;text-decoration: underline;">regex</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 6.0pt;">=".*(</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 6.0pt;text-decoration: underline;">calibri</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 6.0pt;">|</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 6.0pt;text-decoration: underline;">cour</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 6.0pt;">|</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 6.0pt;text-decoration: underline;">arial</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 6.0pt;">|times|comic|</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 6.0pt;text-decoration: underline;">georgia</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 6.0pt;">|impact|LSANS|</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 6.0pt;text-decoration: underline;">pala</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 6.0pt;">|</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 6.0pt;text-decoration: underline;">tahoma</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 6.0pt;">|</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 6.0pt;text-decoration: underline;">trebuc</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 6.0pt;">|</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 6.0pt;text-decoration: underline;">verdana</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 6.0pt;">|symbol|</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 6.0pt;text-decoration: underline;">webdings</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 6.0pt;">|</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 6.0pt;text-decoration: underline;">wingding</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 6.0pt;">).*";</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;">// </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;text-decoration: underline;">Mac</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">// String</span></p>
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;">// </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;text-decoration: underline;">regex</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;">=".*(Courier </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">New|</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;text-decoration: underline;">Arial</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">|Times<span class="" style="white-space:pre-wrap;"> New </span>Roman|Comic</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;text-decoration: underline;">Sans</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">|</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;text-decoration: underline;">Georgia</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">|Impact|</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;text-decoration: underline;">Lucida</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">Console|</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;text-decoration: underline;">Lucida</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;text-decoration: underline;">Sans</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;text-decoration: underline;">Unicode</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">|</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;text-decoration: underline;">Palatino</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;text-decoration: underline;">Linotype</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">|</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;text-decoration: underline;">Tahoma</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">|</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;text-decoration: underline;">Trebuchet</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">|</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;text-decoration: underline;">Verdana</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">|Symbol|</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;text-decoration: underline;">Webdings</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">|</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;text-decoration: underline;">Wingdings</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">|MS</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;text-decoration: underline;">Sans</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;text-decoration: underline;">Serif</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">|MS</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;;white-space:pre-wrap;"> </span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;text-decoration: underline;">Serif</span><span class="DefaultParagraphFont " style="color: #3F7F5F;font-size: 8.0pt;">).*";</span></p>
  
  <p class="Normal DocDefaults "><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">   PhysicalFonts.</span><span class="DefaultParagraphFont " style="color: #000000;font-style: italic;font-size: 8.0pt;">setRegex</span><span class="DefaultParagraphFont " style="color: #000000;font-size: 8.0pt;">(regex);</span><span class="" style="white-space:pre-wrap;"> </span></p>
  
  <p class="Normal DocDefaults "> </p></div>
  
  <div class="footnotes">
  
  <p class="Normal DocDefaults " style="margin-bottom: 0in;line-height: 100%;"> </p>
  
  <p class="FootnoteText Normal DocDefaults "><span class="FootnoteReference DefaultParagraphFont " style="vertical-align: top; font-size: xx-small"><a name="fn1"><a href="#fs1">1</a></a></span><span class="" style="white-space:pre-wrap;"> IBM has their own proprietary JAXB implementation.  By default, WebSphere uses com.ibm.xml.xlxp2.jaxb, which has the concept of fallback/ </span><span class="" style="">MarshallerProxy.  The actual implementation it uses is in com.ibm.jaxb.tools.jar.</span></p>
  
  <p class="FootnoteText Normal DocDefaults "><span class="FootnoteReference DefaultParagraphFont " style="vertical-align: top; font-size: xx-small"><a name="fn2"><a href="#fs2">2</a></a></span><span class="" style="white-space:pre-wrap;"> If you get the error 'Access restriction: The type</span><span class="apple-converted-space DefaultParagraphFont " style=""> </span><span class="underline DefaultParagraphFont " style="white-space:pre-wrap;">is not accessible due to restriction on required library rt.jar' (perhaps using some combination of Eclipse 3.4 and/or JDK 6 update 10?), you need to go into the Build Path for the project, Libraries tab, select the JRE System Library, and add an access rule, "Accessible, **". </span></p>
  
  <p class="FootnoteText Normal DocDefaults "><span class="FootnoteReference DefaultParagraphFont " style="vertical-align: top; font-size: xx-small"><a name="fn3"><a href="#fs3">3</a></a></span><span class="" style="white-space:pre-wrap;"> </span><a href="#null"><span class="Hyperlink DefaultParagraphFont " style="font-size: 9.0pt;">http://blogs.msdn.com/b/dmahugh/archive/2009/01/16/ecma-376-implementation-notes-for-office-2007-sp2.aspx</span></a><span class="" style="white-space:pre-wrap;" /></p>
  
  <p class="FootnoteText Normal DocDefaults "><span class="FootnoteReference DefaultParagraphFont " style="vertical-align: top; font-size: xx-small"><a name="fn4"><a href="#fs4">4</a></a></span><span class="" style="white-space:pre-wrap;"> </span><a href="#null"><span class="Hyperlink DefaultParagraphFont " style="font-size: 9.0pt;">http://blogs.msdn.com/b/dmahugh/archive/2010/04/06/office-s-support-for-iso-iec-29500-strict.aspx</span></a><span class="" style="white-space:pre-wrap;" /></p></div>
  
  
  
  
  
  <!-- userBodyTail goes here -->
  
  </body></html>